On Dec 16, 2010, at 9:45 PM, 谢愈挺 wrote:

> I have a question about "StringImpl::create()". Is it can only input latin1 
> data?

Yes, this method takes latin1 data all const char* arguments in WTFString are 
handled as latin1.
String::fromUTF8 can be used to create strings with utf8 data.

> If it can only input the latin1 data, the following code maybe incorrect:
> In WTFString.cpp :
> String String::format(const char *format, ...)
> {
>  ...
>     Vector<char, 256> buffer;
> ...
>   return StringImpl::create(buffer.data(), len);
> }
>  
> The buffer.data() maybe utf8 data!

The short answer is that String::format should be considered deprecated - its 
behavior is platform-specific, and we'd like to move away from it.

Since all const char* arguments to the String methods are treated as latin1, 
format is not suitable for use with utf8 data – any code that is calling format 
but that may be working with utf8 data needs to be refactored to stop using 
this method (utf8 should be converted to WebCore Strings first, then use the 
other conversion/concatenation methods available).

cheers,
G.


> Thanks.
>  
> pattin
> _______________________________________________
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev

_______________________________________________
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev

Reply via email to