-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <stdint.h>
#include <memory>
-#include <vector>
#include "base/check.h"
#include "base/notreached.h"
ucnv_setFromUCallBack(converter, UCNV_FROM_U_CALLBACK_SKIP, nullptr,
nullptr, nullptr, &status);
break;
- default:
- NOTREACHED();
}
// ucnv_fromUChars returns size not including terminating null
ucnv_setToUCallBack(converter, ToUnicodeCallbackSubstitute, nullptr,
nullptr, nullptr, status);
break;
- default:
- NOTREACHED();
}
}
bool CodepageToUTF16(base::StringPiece encoded,
const char* codepage_name,
OnStringConversionError::Type on_error,
- string16* utf16) {
+ std::u16string* utf16) {
utf16->clear();
UErrorCode status = U_ZERO_ERROR;
size_t uchar_max_length = encoded.length() + 1;
SetUpErrorHandlerForToUChars(on_error, converter, &status);
- std::unique_ptr<char16[]> buffer(new char16[uchar_max_length]);
- int actual_size = ucnv_toUChars(converter, buffer.get(),
- static_cast<int>(uchar_max_length), encoded.data(),
- static_cast<int>(encoded.length()), &status);
+ std::unique_ptr<char16_t[]> buffer(new char16_t[uchar_max_length]);
+ int actual_size = ucnv_toUChars(
+ converter, buffer.get(), static_cast<int>(uchar_max_length),
+ encoded.data(), static_cast<int>(encoded.length()), &status);
ucnv_close(converter);
if (!U_SUCCESS(status)) {
utf16->clear(); // Make sure the output is empty on error.
const std::string& charset,
std::string* result) {
result->clear();
- string16 utf16;
+ std::u16string utf16;
if (!CodepageToUTF16(text, charset.c_str(), OnStringConversionError::FAIL,
&utf16))
return false;