diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-13 19:27:48 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-13 19:27:48 +0000 |
commit | b9f9383602610ef1f94e9bee2d91d7c044e16051 (patch) | |
tree | 8f16f6ff2f2b40bd69cae63fb6ae517ad9d0e35b /base/utf_offset_string_conversions.h | |
parent | 7bc3ca67f1395c1744cb09ac50ff9ddf92f66ab7 (diff) | |
download | chromium_src-b9f9383602610ef1f94e9bee2d91d7c044e16051.zip chromium_src-b9f9383602610ef1f94e9bee2d91d7c044e16051.tar.gz chromium_src-b9f9383602610ef1f94e9bee2d91d7c044e16051.tar.bz2 |
Split *AndAdjustOffset() functions into their own header, to restore utf_string_conversions.h to a simple, readable state.
BUG=4010
TEST=none
Review URL: http://codereview.chromium.org/387012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31928 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/utf_offset_string_conversions.h')
-rw-r--r-- | base/utf_offset_string_conversions.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/base/utf_offset_string_conversions.h b/base/utf_offset_string_conversions.h new file mode 100644 index 0000000..0a1a682 --- /dev/null +++ b/base/utf_offset_string_conversions.h @@ -0,0 +1,35 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef BASE_UTF_OFFSET_STRING_CONVERSIONS_H_ +#define BASE_UTF_OFFSET_STRING_CONVERSIONS_H_ + +#include <string> + +#include "base/string16.h" + +namespace base { +class StringPiece; +} + +// Like the conversions in utf_string_conversions.h, but also take offsets into +// the source strings, which will be adjusted to point at the same logical place +// in the result strings. If this isn't possible because the offsets point past +// the end of the source strings or into the middle of multibyte sequences, they +// will be set to std::wstring::npos. |offset_for_adjustment| may be NULL. +bool UTF8ToWideAndAdjustOffset(const char* src, + size_t src_len, + std::wstring* output, + size_t* offset_for_adjustment); +std::wstring UTF8ToWideAndAdjustOffset(const base::StringPiece& utf8, + size_t* offset_for_adjustment); + +bool UTF16ToWideAndAdjustOffset(const char16* src, + size_t src_len, + std::wstring* output, + size_t* offset_for_adjustment); +std::wstring UTF16ToWideAndAdjustOffset(const string16& utf16, + size_t* offset_for_adjustment); + +#endif // BASE_UTF_OFFSET_STRING_CONVERSIONS_H_ |