Hi Zhiming,
What I guess that happens here, is that you're mixing different
character encodings in one string. The string literals are ASCII -
that's fine. The description.toUTF8() part causes a mix of ASCII and
UTF8, that's fine, although you should write WString::fromUTF8()
around the entire string. I'll assume that description is a WString,
in that case you don't need to do anything. The url comes directly
from readdir, so it is probably encoded in whatever encoding your OS
uses. On Windows, that won't be UTF8. Use an explicit WString
constructor to construct this part: WString(url, std::locale("")); To
put it all together:
return new WText("<a href=\"" + WString(url, std::locale("") + "\"
TARGET=\"_blank\">" + description + "</a>");
Note: I'd use a WAnchor instead.
Best regards,
Wim.
2010/7/4 Zhimin Song <[email protected]>:
> hi, Dule:
>
> You are right about this situation..and like others earlier discusses. but
> how to deal with the following situation:
>
> WText *ComUtil::href(const string &url, const WString &description) {
>
> return new WText("<a href=\"" + url + "\" TARGET=\"_blank\">" +
> description.toUTF8() + "</a>");
> }
>
> it doesn't work corretly, the "url" is the file address, returned by
>
> return_code = readdir_r(dir, &entry, &res)
>
> and
>
> url = addr + entry.d_name
>
> so, this situation, wt does not handle the corrent href display..
>
> Regards
> Zhimin
>
>
> 2010/7/3 Dushan Savich <[email protected]>
>>
>> Hi Yu,
>>
>> This looks to be more related to compiler than to Wt ...
>> C++ doesn't always handle Unicode characters nicely.
>> You should try externalizing strings, at least it always works for me :-)
>> .
>> You could try loading text using WString::tr( .. )
>> [ check out the WMessageResourceBundle -
>>
>> http://www.webtoolkit.eu/wt/doc/reference/html/classWt_1_1WMessageResourceBundle.html
>> ] .
>>
>>
>> Cheers,
>> Dule
>>
>>
>> 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
>> >
>>
>>
>>
>> --
>> Kind Regards,
>> Dushan Savich
>> [email protected]
>> http://stosha.com/
>> +381 64 329 33 55
>> Nehruova 95/51
>> 11070 New Belgrade
>> Belgrade
>> Serbia
>>
>>
>> ------------------------------------------------------------------------------
>> 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
>
>
------------------------------------------------------------------------------
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