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

Side by Side Diff: url/url_canon_internal.cc

Issue 250233002: Remove url::ReadUTFChar's dependency on icu. Use base instead. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix include order Created 6 years, 7 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 | « url/url_canon_internal.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "url/url_canon_internal.h"
6
5 #include <errno.h> 7 #include <errno.h>
6 #include <stdlib.h> 8 #include <stdlib.h>
7 9
8 #include <cstdio> 10 #include <cstdio>
9 #include <string> 11 #include <string>
10 12
11 #include "url/url_canon_internal.h" 13 #include "base/strings/utf_string_conversion_utils.h"
12 14
13 namespace url { 15 namespace url {
14 16
15 namespace { 17 namespace {
16 18
17 template<typename CHAR, typename UCHAR> 19 template<typename CHAR, typename UCHAR>
18 void DoAppendStringOfType(const CHAR* source, int length, 20 void DoAppendStringOfType(const CHAR* source, int length,
19 SharedCharTypes type, 21 SharedCharTypes type,
20 CanonOutput* output) { 22 CanonOutput* output) {
21 for (int i = 0; i < length; i++) { 23 for (int i = 0; i < length; i++) {
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 DoAppendStringOfType<char, unsigned char>(source, length, type, output); 240 DoAppendStringOfType<char, unsigned char>(source, length, type, output);
239 } 241 }
240 242
241 void AppendStringOfType(const base::char16* source, int length, 243 void AppendStringOfType(const base::char16* source, int length,
242 SharedCharTypes type, 244 SharedCharTypes type,
243 CanonOutput* output) { 245 CanonOutput* output) {
244 DoAppendStringOfType<base::char16, base::char16>( 246 DoAppendStringOfType<base::char16, base::char16>(
245 source, length, type, output); 247 source, length, type, output);
246 } 248 }
247 249
250 bool ReadUTFChar(const char* str, int* begin, int length,
251 unsigned* code_point_out) {
252 // This depends on ints and int32s being the same thing. If they're not, it
253 // will fail to compile.
254 // TODO(mmenke): This should probably be fixed.
255 if (!base::ReadUnicodeCharacter(str, length, begin, code_point_out) ||
256 !base::IsValidCharacter(*code_point_out)) {
257 *code_point_out = kUnicodeReplacementCharacter;
258 return false;
259 }
260 return true;
261 }
262
263 bool ReadUTFChar(const base::char16* str, int* begin, int length,
264 unsigned* code_point_out) {
265 // This depends on ints and int32s being the same thing. If they're not, it
266 // will fail to compile.
267 // TODO(mmenke): This should probably be fixed.
268 if (!base::ReadUnicodeCharacter(str, length, begin, code_point_out) ||
269 !base::IsValidCharacter(*code_point_out)) {
270 *code_point_out = kUnicodeReplacementCharacter;
271 return false;
272 }
273 return true;
274 }
275
248 void AppendInvalidNarrowString(const char* spec, int begin, int end, 276 void AppendInvalidNarrowString(const char* spec, int begin, int end,
249 CanonOutput* output) { 277 CanonOutput* output) {
250 DoAppendInvalidNarrowString<char, unsigned char>(spec, begin, end, output); 278 DoAppendInvalidNarrowString<char, unsigned char>(spec, begin, end, output);
251 } 279 }
252 280
253 void AppendInvalidNarrowString(const base::char16* spec, int begin, int end, 281 void AppendInvalidNarrowString(const base::char16* spec, int begin, int end,
254 CanonOutput* output) { 282 CanonOutput* output) {
255 DoAppendInvalidNarrowString<base::char16, base::char16>( 283 DoAppendInvalidNarrowString<base::char16, base::char16>(
256 spec, begin, end, output); 284 spec, begin, end, output);
257 } 285 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 for (int i = 0; i < written; ++i) { 423 for (int i = 0; i < written; ++i) {
396 buffer[i] = static_cast<base::char16>(temp[i]); 424 buffer[i] = static_cast<base::char16>(temp[i]);
397 } 425 }
398 buffer[written] = '\0'; 426 buffer[written] = '\0';
399 return 0; 427 return 0;
400 } 428 }
401 429
402 #endif // !WIN32 430 #endif // !WIN32
403 431
404 } // namespace url 432 } // namespace url
OLDNEW
« no previous file with comments | « url/url_canon_internal.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698