如何让旧的 VC++ 6.0 MFC 程序在 TextBox 或 MessageBox 中读取和显示 UTF8?最好不要破坏当前写入其中的任何文件读取和显示(相当大)。
我将一行读入 CString strStr,然后使用以下代码:
int nLengthNeeded = MultiByteToWideChar(CP_UTF8,0,strStr,1024,0,0);
wchar_t * pWCMessage = new wchar_t[ nLengthNeeded ];
MultiByteToWideChar(CP_UTF8,0,strStr,1024,pWCMessage,nLengthNeeded);
nLengthNeeded = MultiByteToWideChar(CP_UTF8,0,"Error Title",50,0,0);
wchar_t * pWCTitle = new wchar_t[ nLengthNeeded ];
MultiByteToWideChar(CP_UTF8,0,"Error Title",50,pWCTitle,nLengthNeeded);
MessageBoxW(NULL,pWCMessage,pWCTitle,MB_ICONINFORMATION);
仍然不确定如何将其放入文本框中,但事实证明我不需要这样做。