Hello yufeng,

There were problems in previous versions of Wt with how char arrays
were interpreted when converted to a WString. In fact, the situation
was undefined, so we modified the API to allow you to always define
how a char array must be interpreted.
The default constructor of a WString now uses C++'s global locale to
convert a char array to a WString. You can either change the global
locale, or explicitly use a WString constructor that specifies a
locale. For conversions from UTF8, we provide a WString::fromUTF8()
helper function.

But the main probem (there is no portable way to include international
characters in C++ source code) is not solved by this approach. Some
suggestions that may work for you (depending on your compiler and
operating system):
- use WText(L"My chinese character string here"). This will cause your
compiler to use wchar_t to store the characters, and the default
WString constructors correctly converts this string to UTF-8. It's
important to make sure that your compiler knows the correct character
encoding of your C++ source file (sometimes, saving your files in UTF
with a BOM helps).
- use WText(WString::fromUTF8("My chinese character string here")).
Save your file as UTF8. If you're lucky, your compiler does not modify
the byte string as part of its parsing process, and the exact bytes
you entered will be stored in the WString.

My suggestion to write portable code is not to have international
characters in C++ source code.

Best regards,
Wim.

2010/7/3 yufeng <[email protected]>:
> hi:
>  I am chinese,I upgrade wt to wt3.1.3 ,There is a problem about WText.
>  In Wt3.1.3 ,why show like this "hello,����������yggh"?In early wt ,Ok
>  here is my code:
>   ....
>   WText* pUserNameText=new WText("hello,你好!欢迎你来三明日报投稿!
> yyyggh",mpHeaderDiv);
>  pUserNameText->setId("WebUser");
>  .....
>
>
>
>
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Sprint
> What will you do first with EVO, the first 4G phone?
> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
> _______________________________________________
> witty-interest mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/witty-interest
>

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to