Index: base/i18n/icu_string_conversions.h |
=================================================================== |
--- base/i18n/icu_string_conversions.h (revision 31214) |
+++ base/i18n/icu_string_conversions.h (working copy) |
@@ -40,6 +40,17 @@ |
extern const char kCodepageUTF16BE[]; |
extern const char kCodepageUTF16LE[]; |
+// Like CodepageToUTF16() (see below), but also takes an offset into |encoded|, |
+// which will be adjusted to point at the same logical place in |utf16|. If |
+// this isn't possible because it points past the end of |encoded| or into the |
+// middle of a multibyte sequence, it will be set to std::string16::npos. |
+// |offset_for_adjustment| may be NULL. |
+bool CodepageToUTF16AndAdjustOffset(const std::string& encoded, |
+ const char* codepage_name, |
+ OnStringConversionError::Type on_error, |
+ string16* utf16, |
+ size_t* offset_for_adjustment); |
+ |
// Converts between UTF-16 strings and the encoding specified. If the |
// encoding doesn't exist or the encoding fails (when on_error is FAIL), |
// returns false. |
@@ -47,11 +58,24 @@ |
const char* codepage_name, |
OnStringConversionError::Type on_error, |
std::string* encoded); |
+inline bool CodepageToUTF16(const std::string& encoded, |
+ const char* codepage_name, |
+ OnStringConversionError::Type on_error, |
+ string16* utf16) { |
+ return CodepageToUTF16AndAdjustOffset(encoded, codepage_name, on_error, utf16, |
+ NULL); |
+} |
-bool CodepageToUTF16(const std::string& encoded, |
- const char* codepage_name, |
- OnStringConversionError::Type on_error, |
- string16* utf16); |
+// Like CodepageToWide() (see below), but also takes an offset into |encoded|, |
+// which will be adjusted to point at the same logical place in |wide|. If |
+// this isn't possible because it points past the end of |encoded| or into the |
+// middle of a multibyte sequence, it will be set to std::wstring::npos. |
+// |offset_for_adjustment| may be NULL. |
+bool CodepageToWideAndAdjustOffset(const std::string& encoded, |
+ const char* codepage_name, |
+ OnStringConversionError::Type on_error, |
+ std::wstring* wide, |
+ size_t* offset_for_adjustment); |
// Converts between wide strings and the encoding specified. If the |
// encoding doesn't exist or the encoding fails (when on_error is FAIL), |
@@ -60,10 +84,13 @@ |
const char* codepage_name, |
OnStringConversionError::Type on_error, |
std::string* encoded); |
-bool CodepageToWide(const std::string& encoded, |
- const char* codepage_name, |
- OnStringConversionError::Type on_error, |
- std::wstring* wide); |
+inline bool CodepageToWide(const std::string& encoded, |
+ const char* codepage_name, |
+ OnStringConversionError::Type on_error, |
+ std::wstring* wide) { |
+ return CodepageToWideAndAdjustOffset(encoded, codepage_name, on_error, wide, |
+ NULL); |
+} |
} // namespace base |