ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  C++(MFC) messy code(Chinese)
Posted by dgongdgong on Dec-02-2016 21:40
I have a question about using addText method in a AngularMeter  object:when I set the text in Chinese,it can't display correct.I don't know  how should I do! Help!!!
       Thanks!

  Re: C++(MFC) messy code(Chinese)
Posted by Peter Kwan on Dec-03-2016 04:01
Attachments:
Hi dgongdgong,

ChartDirector for C++ uses the UTF8 encoding for text strings, so it can support all unicode characters, including Chinese.

To create a chart with Chinese characters, please ensure that the text string is encoded in UTF8, and your code is using a font that can support Chinese characters.

If the Chinese characters are entered as text in the source code, and the text is not in UTF8, but in another encoding that is supported by the compiler, you can ask the compiler to compiler the text into unicode strings (wchar_t* or L strings) or MFC strings (_T strings), and then use the ChartDirector WCHARtoUTF8 or TCHARtoUTF8 to convert them to UTF8. For example:

m->addText(150, 125, WCHARtoUTF8(L"处理器"), "simsun.ttc", 15, Chart::TextColor,
        Chart::BottomCenter);

Note that in the above code, I use L string (unicode string), then use WCHARtoUTF8 to convert it to UTF8. I also use "simsun.ttc" as the font, as this font supports Chinese characters. (Make sure the computer has the necessary font.)

Hope this can help.

Regards
Peter Kwan
semicirclemeter.png