convert unicode to char

前端 未结 4 578
礼貌的吻别
礼貌的吻别 2021-01-16 07:42

How can I convert a Unicode string to a char* or char* const in embarcadero c++ ?

4条回答
  •  囚心锁ツ
    2021-01-16 08:35

    If you work with Windows:

    //#include 
    u16string utext = u"объява";
    char text[0x100];
    WideCharToMultiByte(CP_UTF8,NULL,(const wchar_t*)(utext.c_str()),-1,text,-1,NULL,NULL);
    cout << text;
    

    We can't use std::wstring_convert, wherefore is not available in MinGW 4.9.2.

提交回复
热议问题