Project

General

Profile

Actions

Support #3685

closed

wiggets display Chinese character

Added by Anonymous almost 10 years ago. Updated almost 10 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
11/26/2014
Due date:
% Done:

0%

Estimated time:

Description

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?

Actions #1

Updated by Wim Dumon almost 10 years ago

  • Status changed from New to Resolved

Hey,

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,

Wim.

Actions #2

Updated by Koen Deforche almost 10 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
Actions

Also available in: Atom PDF