Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(437)

Unified Diff: third_party/WebKit/Source/wtf/text/WTFString.h

Issue 1768063002: Introduce String::fromUTF8Lenient() and use it for cache_name in CacheStorage API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: incorporated jsbell's comment Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/wtf/text/UTF8.cpp ('k') | third_party/WebKit/Source/wtf/text/WTFString.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/text/WTFString.h
diff --git a/third_party/WebKit/Source/wtf/text/WTFString.h b/third_party/WebKit/Source/wtf/text/WTFString.h
index 0b1b4ea8fd153ea6f4baae0726940c95b34a97f1..b05dbc89a2a191a181dc02421220670d2ce28148 100644
--- a/third_party/WebKit/Source/wtf/text/WTFString.h
+++ b/third_party/WebKit/Source/wtf/text/WTFString.h
@@ -428,9 +428,10 @@ public:
static String make16BitFrom8BitSource(const LChar*, size_t);
- // String::fromUTF8 will return a null string if
- // the input data contains invalid UTF-8 sequences.
- static String fromUTF8(const LChar*, size_t);
+ // String::fromUTF8 will return a null string if the input data contains
+ // invalid UTF-8 sequences. When |strict| is false, isolated surrogates are
+ // converted.
+ static String fromUTF8(const LChar*, size_t, bool strict = true);
static String fromUTF8(const LChar*);
static String fromUTF8(const char* s, size_t length) { return fromUTF8(reinterpret_cast<const LChar*>(s), length); }
static String fromUTF8(const char* s) { return fromUTF8(reinterpret_cast<const LChar*>(s)); }
@@ -441,6 +442,10 @@ public:
static String fromUTF8WithLatin1Fallback(const LChar*, size_t);
static String fromUTF8WithLatin1Fallback(const char* s, size_t length) { return fromUTF8WithLatin1Fallback(reinterpret_cast<const LChar*>(s), length); }
+ // Helper methods to call fromUTF8() with |strict| = false.
+ static String fromUTF8Lenient(const LChar* s, size_t length) { return fromUTF8(s, length, false); }
+ static String fromUTF8Lenient(const char* s, size_t length) { return fromUTF8Lenient(reinterpret_cast<const LChar*>(s), length); }
+
bool containsOnlyASCII() const;
bool containsOnlyLatin1() const;
bool containsOnlyWhitespace() const { return !m_impl || m_impl->containsOnlyWhitespace(); }
« no previous file with comments | « third_party/WebKit/Source/wtf/text/UTF8.cpp ('k') | third_party/WebKit/Source/wtf/text/WTFString.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698