Home > Back-end >  Wstring Chinese output noise, (already wcout imbue (locale (" CHS "))) and the great spiri
Wstring Chinese output noise, (already wcout imbue (locale (" CHS "))) and the great spiri

Time:09-26

CodePudding user response:

Try the UnicodeString to define variables

CodePudding user response:

Is set, the building Lord, you put the L "string" changing _T (" string ") form to try again

CodePudding user response:

WideCharToMultiByte
MultiByteToWideChar
Can solve your problem, research the usage

CodePudding user response:

Console the default active code page of the building Lord not simplified Chinese, run CHCP see display many, run CHCP 936 more into simplified Chinese code page with respect to OK,

CodePudding user response:

Try using this since I write function ~
STD: : string UTF8_To_string (const STD: : string & amp; STR)
{
Int nwLen=MultiByteToWideChar (CP_UTF8, 0, STR c_str (), 1, NULL, 0).

Would be * pwBuf=new would [nwLen + 1];//must add 1, otherwise there will be a tail
Memset (pwBuf, 0, nwLen * 2 + 2);

MultiByteToWideChar (CP_UTF8, 0, STR c_str (), STR. The length (), pwBuf, nwLen);

Int nLen=WideCharToMultiByte (pwBuf CP_ACP, 0, 1, NULL, NULL, NULL, NULL);

Char * pbufs=new char [nLen + 1];
Memset (pbufs, 0, nLen + 1);

WideCharToMultiByte (CP_ACP, 0, pwBuf nwLen, pbufs, nLen, NULL, NULL);

STD: : string retStr=pbufs;

The delete [] pbufs;
The delete [] pwBuf;

Pbufs=NULL;
PwBuf=NULL;

Return retStr;
}
  • Related