[Webkit-unassigned] [Bug 92872] A smart util class that grabs latin1 string from a WTF::String
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Wed Aug 1 11:35:19 PDT 2012
https://bugs.webkit.org/show_bug.cgi?id=92872
--- Comment #3 from Yong Li <yoli at rim.com> 2012-08-01 11:35:20 PST ---
(In reply to comment #2)
> It seems to me that the only case you always want a const char* that is Latin 1 is for debugging or logging. If the string is a 16 bit string, then there is loss of data calling String::latin1().
>
> For the performant cases of handling strings, you need to do the is8Bit() check and then handle the 8 and 16 bit cases separately.
>
> Therefore use str.latin1.data() for those debug / logging cases.
We also want to convert WTF::String to const char* when communicating with 3rd party libraries or port-specific API. For example, when forwarding a network request to libcurl, we have to convert a url from KURL to const char*. In most cases KURL has a 8-bit string internally, but it is not safe to assume that's always true.
(In reply to comment #1)
> Can CString be changed to use String's internal 8-bit buffer when possible without copying? Introducing a new class seems a little heavy-handed.
I think it is possible: let CString have a RefPtr<StringImpl> as a member, and it also has to make sure the 8-bit buffer has a null terminator...
Another idea: Add a non-const method ensure8Bit() to String, so developer can get a copy of the string, call this method, and then directly use characters8() without worrying about crashes.
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list