| OLD | NEW |
| 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 #include "base/i18n/icu_string_conversions.h" | 5 #include "base/i18n/icu_string_conversions.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "unicode/ucnv.h" | 12 #include "unicode/ucnv.h" |
| 13 #include "unicode/ucnv_cb.h" | 13 #include "unicode/ucnv_cb.h" |
| 14 #include "unicode/ucnv_err.h" | 14 #include "unicode/ucnv_err.h" |
| 15 #include "unicode/ustring.h" | 15 #include "unicode/ustring.h" |
| 16 | 16 |
| 17 namespace base { | 17 namespace base { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | |
| 21 inline bool IsValidCodepoint(uint32 code_point) { | |
| 22 // Excludes the surrogate code points ([0xD800, 0xDFFF]) and | |
| 23 // codepoints larger than 0x10FFFF (the highest codepoint allowed). | |
| 24 // Non-characters and unassigned codepoints are allowed. | |
| 25 return code_point < 0xD800u || | |
| 26 (code_point >= 0xE000u && code_point <= 0x10FFFFu); | |
| 27 } | |
| 28 | |
| 29 // ToUnicodeCallbackSubstitute() is based on UCNV_TO_U_CALLBACK_SUSBSTITUTE | 20 // ToUnicodeCallbackSubstitute() is based on UCNV_TO_U_CALLBACK_SUSBSTITUTE |
| 30 // in source/common/ucnv_err.c. | 21 // in source/common/ucnv_err.c. |
| 31 | 22 |
| 32 // Copyright (c) 1995-2006 International Business Machines Corporation | 23 // Copyright (c) 1995-2006 International Business Machines Corporation |
| 33 // and others | 24 // and others |
| 34 // | 25 // |
| 35 // All rights reserved. | 26 // All rights reserved. |
| 36 // | 27 // |
| 37 | 28 |
| 38 // Permission is hereby granted, free of charge, to any person obtaining a | 29 // Permission is hereby granted, free of charge, to any person obtaining a |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 return false; | 258 return false; |
| 268 } | 259 } |
| 269 | 260 |
| 270 // actual_size is # of bytes. | 261 // actual_size is # of bytes. |
| 271 wide->resize(actual_size / sizeof(wchar_t)); | 262 wide->resize(actual_size / sizeof(wchar_t)); |
| 272 return true; | 263 return true; |
| 273 #endif // defined(WCHAR_T_IS_UTF32) | 264 #endif // defined(WCHAR_T_IS_UTF32) |
| 274 } | 265 } |
| 275 | 266 |
| 276 } // namespace base | 267 } // namespace base |
| OLD | NEW |