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
3// found in the LICENSE file.
4
5#ifndef BASE_UTF_OFFSET_STRING_CONVERSIONS_H_
6#define BASE_UTF_OFFSET_STRING_CONVERSIONS_H_
7
8#include <string>
9
10#include "base/string16.h"
11
12namespace base {
13class StringPiece;
14}
15
16// Like the conversions in utf_string_conversions.h, but also take offsets into
17// the source strings, which will be adjusted to point at the same logical place
18// in the result strings.  If this isn't possible because the offsets point past
19// the end of the source strings or into the middle of multibyte sequences, they
20// will be set to std::wstring::npos.  |offset_for_adjustment| may be NULL.
21bool UTF8ToWideAndAdjustOffset(const char* src,
22                               size_t src_len,
23                               std::wstring* output,
24                               size_t* offset_for_adjustment);
25std::wstring UTF8ToWideAndAdjustOffset(const base::StringPiece& utf8,
26                                       size_t* offset_for_adjustment);
27
28bool UTF16ToWideAndAdjustOffset(const char16* src,
29                                size_t src_len,
30                                std::wstring* output,
31                                size_t* offset_for_adjustment);
32std::wstring UTF16ToWideAndAdjustOffset(const string16& utf16,
33                                        size_t* offset_for_adjustment);
34
35#endif  // BASE_UTF_OFFSET_STRING_CONVERSIONS_H_
36