Allow WebString.utf8() to take UTF8ConversionMode
Currently WebString.utf8() always converts the internal string to UTF-8
with LenientUTF8Conversion mode (if the string is not ascii), but
WebString::fromUTF8() only takes valid, strict UTF-8 string.
therefore
the same string may not be able to be converted back to WebString.
This has been causing a few issues:
- UTF16 (WTFString) -> UTF8 -> UTF16 (WTFString) round trip doesn't work
- Works differently from base::UTF16ToUTF8, and some code explicitly
calls base version via .utf16() to avoid any problems while it could
be more costly than .utf8() if the internal string is ascii/latin.
Similar but opposite attempt has been made in the past in
https://codereview.chromium.org/1768063002/
but hadn't landed as leniently converted UTF8 is not valid and probably
should not be accepted.
BUG=667131
Review-Url: https://codereview.chromium.org/2629573002
Cr-Original-Commit-Position: refs/heads/master@{#444008}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: d280d3b7b888a5f8964e916cdc2360ebc7858418
1 file changed