summaryrefslogtreecommitdiffstats
path: root/base/utf_string_conversion_utils.h
diff options
context:
space:
mode:
authorjschuh@google.com <jschuh@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-26 23:39:58 +0000
committerjschuh@google.com <jschuh@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-26 23:39:58 +0000
commitbce55e2762118f3dc567afdd3a7af137899f783a (patch)
treebc7815b3a881e3e1017534f8864164599942621c /base/utf_string_conversion_utils.h
parentef37e08636e4d5e4be1aa4b14a9e2d3d57fc2cfb (diff)
downloadchromium_src-bce55e2762118f3dc567afdd3a7af137899f783a.zip
chromium_src-bce55e2762118f3dc567afdd3a7af137899f783a.tar.gz
chromium_src-bce55e2762118f3dc567afdd3a7af137899f783a.tar.bz2
Make IsStringUTF8 reject (U+FDD0 .. U+FDEF)
Eliminated the old Mozilla implementation and used an ICU-based implementation. BUG=2759 TEST=base_unittests --gtest_filter=StringUtilTest.IsStringUTF8 Review URL: http://codereview.chromium.org/661205 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40178 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/utf_string_conversion_utils.h')
-rw-r--r--base/utf_string_conversion_utils.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/base/utf_string_conversion_utils.h b/base/utf_string_conversion_utils.h
index a8a76c5..0c02d82 100644
--- a/base/utf_string_conversion_utils.h
+++ b/base/utf_string_conversion_utils.h
@@ -19,6 +19,14 @@ inline bool IsValidCodepoint(uint32 code_point) {
(code_point >= 0xE000u && code_point <= 0x10FFFFu);
}
+inline bool IsValidCharacter(uint32 code_point) {
+ // Excludes non-characters (U+FDD0..U+FDEF, and all codepoints ending in
+ // 0xFFFE or 0xFFFF) from the set of valid code points.
+ return code_point < 0xD800u || (code_point >= 0xE000u &&
+ code_point < 0xFDD0u) || (code_point > 0xFDEFu &&
+ code_point <= 0x10FFFFu && (code_point & 0xFFFEu) != 0xFFFEu);
+}
+
// ReadUnicodeCharacter --------------------------------------------------------
// Reads a UTF-8 stream, placing the next code point into the given output