summaryrefslogtreecommitdiffstats
path: root/base/utf_offset_string_conversions.h
blob: 0a1a682add442fbd0a87d38b7c29bc70e42d8132 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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_