|
show chinese character store in CString, unicode project |
Posted by show CString content on Dec-28-2016 23:29 |
|
1、Which way can show the CString content in MFC unicode project with "TCHARtoUTF8".
2、I can not find "TCHARtoUTF8" in chartdir header file. |
Re: show chinese character store in CString, unicode project |
Posted by JianweiChen on Dec-28-2016 23:58 |
|
I had found the way. Just translate the characters from CString to char(UTF8) with "WideCharToMultiByte". |
Re: show chinese character store in CString, unicode project |
Posted by Peter Kwan on Dec-29-2016 01:36 |
|
Hi JianweiChen,
The TCHARtoUTF8 is included in the ChartViewer.h header file, which is normally used in MFC projects. (CString is the text string in the MFC framework.)
As CString can implicitly convert to TCHAR*, so it should be able to be used in TCHARtoUTF8 directly, like:
CString sss = TEXT("ABCD");
c->addTitle(TCHARtoUTF8(sss));
Internally, TCHARtoUTF8 just uses WideCharToMultiByte if the TCHAR is configured to be wide char. Of course, you can also use WideCharToMultiByte directly in your code for the conversion.
Regards
Peter Kwan |
|