C++ sdl屏幕UTF8屏幕窗口标题

C++ sdl屏幕UTF8屏幕窗口标题,c++,utf-8,screen,sdl,caption,C++,Utf 8,Screen,Sdl,Caption,我试图在我的sdl项目中设置UTF8屏幕窗口标题,我看到的只是,,我不知道如何处理它。以下是我的示例代码: #include "SDL/SDL.h" int main( int argc, char* args[] ) { int screen_width = 800; int screen_hight = 600; int screen_bpp = 32; SDL_Surface *screen = NULL; SDL_Init( SDL_IN

我试图在我的sdl项目中设置UTF8屏幕窗口标题,我看到的只是
,我不知道如何处理它。以下是我的示例代码:

#include "SDL/SDL.h"

int main( int argc, char* args[] )
{
    int screen_width = 800;
    int screen_hight = 600;
    int screen_bpp = 32;
    SDL_Surface *screen = NULL;
        SDL_Init( SDL_INIT_EVERYTHING );
    screen = SDL_SetVideoMode( screen_width, screen_hight, screen_bpp, SDL_SWSURFACE  );

        // Set the window caption
        SDL_WM_SetCaption( "تستی", NULL ); //utf8 not working
        SDL_Delay(5000);
        SDL_Flip(screen);

}

像这样输入它是行不通的,除非通过某种编译器扩展。您可以将其转换为UTF-8代码单位(例如):

D8 AA D8 B3 D8 AA DB 8C

然后使用十六进制转义符(
\xHH
其中
HH
是十六进制值)将其转换为字符文字:

如果您的系统能够显示,这应该可以工作

显然,如果您有很多UTF-8字符串,那么这样做很乏味,您可以将它们放入UTF-8编码的文件中并从中读取,或者查看编译器是否支持UTF-8文本(它们看起来像:
u8“تتی”

SDL_WM_SetCaption( "\xD8\xAA\xD8\xB3\xD8\xAA\xDB\x8C", NULL );