1 // Copyright (c) 2017 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.
5 #ifndef BASE_I18N_UNICODESTRING_H_
6 #define BASE_I18N_UNICODESTRING_H_
8 #include "base/strings/string16.h"
9 #include "third_party/icu/source/common/unicode/unistr.h"
10 #include "third_party/icu/source/common/unicode/uvernum.h"
12 #if U_ICU_VERSION_MAJOR_NUM >= 59
13 #include "third_party/icu/source/common/unicode/char16ptr.h"
19 inline string16 UnicodeStringToString16(const icu::UnicodeString& unistr) {
20 #if U_ICU_VERSION_MAJOR_NUM >= 59
21 return base::string16(icu::toUCharPtr(unistr.getBuffer()),
22 static_cast<size_t>(unistr.length()));
24 return base::string16(unistr.getBuffer(),
25 static_cast<size_t>(unistr.length()));
32 #endif // BASE_UNICODESTRING_H_