1 // Copyright 2017 The Chromium Authors
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_
10 #include "third_party/icu/source/common/unicode/unistr.h"
11 #include "third_party/icu/source/common/unicode/uvernum.h"
13 #if U_ICU_VERSION_MAJOR_NUM >= 59
14 #include "third_party/icu/source/common/unicode/char16ptr.h"
20 inline std::u16string UnicodeStringToString16(
21 const icu::UnicodeString& unistr) {
22 #if U_ICU_VERSION_MAJOR_NUM >= 59
23 return std::u16string(icu::toUCharPtr(unistr.getBuffer()),
24 static_cast<size_t>(unistr.length()));
26 return std::u16string(unistr.getBuffer(),
27 static_cast<size_t>(unistr.length()));
34 #endif // BASE_I18N_UNICODESTRING_H_