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

Side by Side Diff: base/utf_string_conversion_utils.h

Issue 552026: Revert 36459 - Breaks 7 WebKit tests... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/string_util_unittest.cc ('k') | base/utf_string_conversions_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_UTF_STRING_CONVERSION_UTILS_H_ 5 #ifndef BASE_UTF_STRING_CONVERSION_UTILS_H_
6 #define BASE_UTF_STRING_CONVERSION_UTILS_H_ 6 #define BASE_UTF_STRING_CONVERSION_UTILS_H_
7 7
8 // This should only be used by the various UTF string conversion files. 8 // This should only be used by the various UTF string conversion files.
9 9
10 #include "base/string16.h" 10 #include "base/string16.h"
11 11
12 namespace base { 12 namespace base {
13 13
14 inline bool IsValidCodepoint(uint32 code_point) { 14 inline bool IsValidCodepoint(uint32 code_point) {
15 // Excludes non-characters (U+FDD0..U+FDEF, and all codepoints ending in 15 // Excludes the surrogate code points ([0xD800, 0xDFFF]) and
16 // 0xFFFE or 0xFFFF), surrogate code points (U+D800..U+DFFF), and codepoints 16 // codepoints larger than 0x10FFFF (the highest codepoint allowed).
17 // larger than U+10FFFF (the highest codepoint allowed). 17 // Non-characters and unassigned codepoints are allowed.
18 return code_point < 0xD800u || (code_point >= 0xE000u && 18 return code_point < 0xD800u ||
19 code_point < 0xFDD0u) || (code_point > 0xFDEFu && 19 (code_point >= 0xE000u && code_point <= 0x10FFFFu);
20 code_point <= 0x10FFFFu && (code_point & 0xFFFEu) != 0xFFFEu);
21 } 20 }
22 21
23 // ReadUnicodeCharacter -------------------------------------------------------- 22 // ReadUnicodeCharacter --------------------------------------------------------
24 23
25 // Reads a UTF-8 stream, placing the next code point into the given output 24 // Reads a UTF-8 stream, placing the next code point into the given output
26 // |*code_point|. |src| represents the entire string to read, and |*char_index| 25 // |*code_point|. |src| represents the entire string to read, and |*char_index|
27 // is the character offset within the string to start reading at. |*char_index| 26 // is the character offset within the string to start reading at. |*char_index|
28 // will be updated to index the last character read, such that incrementing it 27 // will be updated to index the last character read, such that incrementing it
29 // (as in a for loop) will take the reader to the next character. 28 // (as in a for loop) will take the reader to the next character.
30 // 29 //
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 void PrepareForUTF8Output(const CHAR* src, size_t src_len, std::string* output); 77 void PrepareForUTF8Output(const CHAR* src, size_t src_len, std::string* output);
79 78
80 // Prepares an output buffer (containing either UTF-16 or -32 data) given some 79 // Prepares an output buffer (containing either UTF-16 or -32 data) given some
81 // UTF-8 input that will be converted to it. See PrepareForUTF8Output(). 80 // UTF-8 input that will be converted to it. See PrepareForUTF8Output().
82 template<typename STRING> 81 template<typename STRING>
83 void PrepareForUTF16Or32Output(const char* src, size_t src_len, STRING* output); 82 void PrepareForUTF16Or32Output(const char* src, size_t src_len, STRING* output);
84 83
85 } // namespace base 84 } // namespace base
86 85
87 #endif // BASE_UTF_STRING_CONVERSION_UTILS_H_ 86 #endif // BASE_UTF_STRING_CONVERSION_UTILS_H_
OLDNEW
« no previous file with comments | « base/string_util_unittest.cc ('k') | base/utf_string_conversions_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698