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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
From fd5b3e755df541b44128caed625215017ef59989 Mon Sep 17 00:00:00 2001
From: jshin <jshin@chromium.org>
Date: Thu, 9 Mar 2017 12:01:15 -0800
Subject: [PATCH] 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}
---
src/i18n.cc | 12 +++++++++++-
src/runtime/runtime-i18n.cc | 10 ++++++----
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/v8/src/i18n.cc b/v8/src/i18n.cc
index d2245ef34a9..7c22871ff5e 100644
--- a/v8/src/i18n.cc
+++ b/v8/src/i18n.cc
@@ -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);
diff --git a/v8/src/runtime/runtime-i18n.cc b/v8/src/runtime/runtime-i18n.cc
index 0b453819146..e89175a37db 100644
--- a/v8/src/runtime/runtime-i18n.cc
+++ b/v8/src/runtime/runtime-i18n.cc
@@ -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();
|