| 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 #ifndef CHROME_BROWSER_SYNC_UTIL_CHARACTER_SET_CONVERTERS_H_ | 5 #ifndef CHROME_BROWSER_SYNC_UTIL_CHARACTER_SET_CONVERTERS_H_ |
| 6 #define CHROME_BROWSER_SYNC_UTIL_CHARACTER_SET_CONVERTERS_H_ | 6 #define CHROME_BROWSER_SYNC_UTIL_CHARACTER_SET_CONVERTERS_H_ |
| 7 | 7 |
| 8 // A pair of classes to convert UTF8 <-> UCS2 character strings. | 8 // A pair of classes to convert UTF8 <-> UCS2 character strings. |
| 9 // | 9 // |
| 10 // Note that the current implementation is limited to UCS2, whereas the | 10 // Note that the current implementation is limited to UCS2, whereas the |
| 11 // interface is agnostic to the wide encoding used. | 11 // interface is agnostic to the wide encoding used. |
| 12 // | 12 // |
| 13 // Also note that UCS2 is different from UTF-16, in that UTF-16 can encode all | 13 // Also note that UCS2 is different from UTF-16, in that UTF-16 can encode all |
| 14 // the code points in the Unicode character set by multi-character encodings, | 14 // the code points in the Unicode character set by multi-character encodings, |
| 15 // while UCS2 is limited to encoding < 2^16 code points. | 15 // while UCS2 is limited to encoding < 2^16 code points. |
| 16 // | 16 // |
| 17 // It appears that Windows support UTF-16, which means we have to be careful | 17 // It appears that Windows support UTF-16, which means we have to be careful |
| 18 // what we feed this class. | 18 // what we feed this class. |
| 19 // | 19 // |
| 20 // Usage: | 20 // Usage: |
| 21 // string utf8; | 21 // string utf8; |
| 22 // CHECK(browser_sync::Append(wide_string, &utf8)); | 22 // CHECK(browser_sync::Append(wide_string, &utf8)); |
| 23 // PathString bob; | 23 // PathString bob; |
| 24 // CHECK(browser_sync::Append(utf8, &bob)); | 24 // CHECK(browser_sync::Append(utf8, &bob)); |
| 25 // PathString fred = bob; | 25 // PathString fred = bob; |
| 26 | 26 |
| 27 #ifdef OS_LINUX | |
| 28 #include <glib.h> | |
| 29 #endif | |
| 30 | |
| 31 #include <string> | 27 #include <string> |
| 32 | 28 |
| 33 #include "base/basictypes.h" | 29 #include "base/basictypes.h" |
| 34 #include "base/logging.h" | 30 #include "base/logging.h" |
| 35 #include "base/string16.h" | 31 #include "base/string16.h" |
| 36 #include "chrome/browser/sync/util/sync_types.h" | 32 #include "chrome/browser/sync/util/sync_types.h" |
| 37 | 33 |
| 38 // Need to cast literals (Linux, OSX) | 34 // Need to cast literals (Linux, OSX) |
| 39 #define STRING16_UGLY_DOUBLE_DEFINE_HACK(s) \ | 35 #define STRING16_UGLY_DOUBLE_DEFINE_HACK(s) \ |
| 40 reinterpret_cast<const char16*>(L##s) | 36 reinterpret_cast<const char16*>(L##s) |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 inline PathString::size_type ToPathString::length() const { | 223 inline PathString::size_type ToPathString::length() const { |
| 228 DCHECK(good_ && good_checked_); | 224 DCHECK(good_ && good_checked_); |
| 229 return result_.length(); | 225 return result_.length(); |
| 230 } | 226 } |
| 231 | 227 |
| 232 void TrimPathStringToValidCharacter(PathString* string); | 228 void TrimPathStringToValidCharacter(PathString* string); |
| 233 | 229 |
| 234 } // namespace browser_sync | 230 } // namespace browser_sync |
| 235 | 231 |
| 236 #endif // CHROME_BROWSER_SYNC_UTIL_CHARACTER_SET_CONVERTERS_H_ | 232 #endif // CHROME_BROWSER_SYNC_UTIL_CHARACTER_SET_CONVERTERS_H_ |
| OLD | NEW |