Commit fd5b3e75 authored by jshin's avatar jshin Committed by Commit bot

Prepare for ICU's switch to char16_t

ICU's UChar was uint16_t (non-Win) or wchar_t (Windows). It's switching
to char16_t in both C/C++ API. It needs some changes. Fortunately,
v8 needs only a couple of changes because v8 has been using
reinterpret_cast in many places calling ICU API.

This change was confirmed to work fine with ICU-59-to-be.

BUG=v8:6062
TEST=trybot

Review-Url: https://codereview.chromium.org/2738503008
Cr-Commit-Position: refs/heads/master@{#43707}
parent 9ac64ca1
......@@ -30,8 +30,13 @@
#include "unicode/ucol.h"
#include "unicode/ucurr.h"
#include "unicode/unum.h"
#include "unicode/uvernum.h"
#include "unicode/uversion.h"
#if U_ICU_VERSION_MAJOR_NUM >= 59
#include "unicode/char16ptr.h"
#endif
namespace v8 {
namespace internal {
......@@ -270,8 +275,13 @@ icu::DecimalFormat* CreateICUNumberFormat(
}
UErrorCode status_digits = U_ZERO_ERROR;
#if U_ICU_VERSION_MAJOR_NUM >= 59
uint32_t fraction_digits = ucurr_getDefaultFractionDigits(
currency.getTerminatedBuffer(), &status_digits);
icu::toUCharPtr(currency.getTerminatedBuffer()), &status_digits);
#else
uint32_t fraction_digits = ucurr_getDefaultFractionDigits(
currency.getTerminatedBuffer(), &status_digits);
#endif
if (U_SUCCESS(status_digits)) {
number_format->setMinimumFractionDigits(fraction_digits);
number_format->setMaximumFractionDigits(fraction_digits);
......
......@@ -43,6 +43,7 @@
#include "unicode/uloc.h"
#include "unicode/unistr.h"
#include "unicode/unum.h"
#include "unicode/ustring.h"
#include "unicode/uversion.h"
......@@ -609,10 +610,11 @@ RUNTIME_FUNCTION(Runtime_InternalCompare) {
String::FlatContent flat2 = string2->GetFlatContent();
std::unique_ptr<uc16[]> sap1;
std::unique_ptr<uc16[]> sap2;
const UChar* string_val1 = GetUCharBufferFromFlat(flat1, &sap1, length1);
const UChar* string_val2 = GetUCharBufferFromFlat(flat2, &sap2, length2);
result =
collator->compare(string_val1, length1, string_val2, length2, status);
icu::UnicodeString string_val1(
FALSE, GetUCharBufferFromFlat(flat1, &sap1, length1), length1);
icu::UnicodeString string_val2(
FALSE, GetUCharBufferFromFlat(flat2, &sap2, length2), length2);
result = collator->compare(string_val1, string_val2, status);
}
if (U_FAILURE(status)) return isolate->ThrowIllegalOperation();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment