Support #3685

wiggets display Chinese character

Added by Anonymous over 8 years ago. Updated over 8 years ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:


In a application I create a widget like WText to display Chinese character such as "你好".However,the character displayed messy code .how to set rightly?


Updated by Wim Dumon over 8 years ago

  • Status changed from New to Resolved


Anywhere where Wt supports unicode in the interface, it uses the Wt::WString class. Look at the constructors of WString to see how you can specify the encoding of the source string when you create a new WStrings. Once the WString is properly created, you don't have to worry about character format anymore (internally it uses UTF-8).

To avoid all encoding related issues with foreign language characters/string literals in source code (which is not standardized by the C standard last time I checked), we strongly recommend to put all characters in a message resource bundle, thus an UTF-8 encoded XML file, rather than to include them in the source code.

If you nevertheless use string literals in your source code, either write L"你好" or save your file in UTF8 format (your compiler too) and use Wt's WString::fromUTF8("你好") to convert a string literal to a WString.

If your strings come from somewhere else (a file, a database), use the proper constructor to convert the string to a WString. For UTF-8, this will be WString::fromUTF8(somestring).

Best regards,



Updated by Koen Deforche over 8 years ago

  • Tracker changed from Bug to Support
  • Status changed from Resolved to Closed
  • Assignee set to Wim Dumon
  • Target version set to 3.3.4

Also available in: Atom PDF