Skip to content

Commit 7f1ab68

Browse files
committed
[MERGE #4952 @kfarnung] Set U_USING_ICU_NAMESPACE to 0 by default
Merge pull request #4952 from kfarnung:icu61 ICU61 updated the value of `U_USING_ICU_NAMESPACE` to 0 by default. In order to maintain compatibility this change updates our ICU includes to match and adds the `icu::` namespace explicitly when needed. Refs: nodejs/node#18667 Refs: https://ssl.icu-project.org/trac/ticket/13460
2 parents 8e52453 + a4ae437 commit 7f1ab68

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

lib/Runtime/Library/RuntimeLibraryPch.h

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
#ifdef INTL_ICU
102102
#define U_STATIC_IMPLEMENTATION
103103
#define U_SHOW_CPLUSPLUS_API 0
104+
#define U_USING_ICU_NAMESPACE 0
104105
#pragma warning(push)
105106
#pragma warning(disable:4995)
106107
#include <unicode/uloc.h>

lib/Runtime/PlatformAgnostic/Platform/Common/Intl.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ typedef uint64_t uint64;
4646

4747
#define U_STATIC_IMPLEMENTATION
4848
#define U_SHOW_CPLUSPLUS_API 1
49+
#define U_USING_ICU_NAMESPACE 0
4950
#pragma warning(push)
5051
#pragma warning(disable:4995) // deprecation warning
5152
#include <unicode/uloc.h>

lib/Runtime/PlatformAgnostic/Platform/Linux/UnicodeText.ICU.cpp

+12-11
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "RuntimePlatformAgnosticPch.h"
77
#include "UnicodeText.h"
88
#ifdef HAS_REAL_ICU
9+
#define U_USING_ICU_NAMESPACE 0
910
#include <unicode/uchar.h>
1011
#include <unicode/ustring.h>
1112
#include <unicode/normalizer2.h>
@@ -31,24 +32,24 @@ namespace PlatformAgnostic
3132

3233
#ifdef HAS_REAL_ICU
3334
// Helper ICU conversion facilities
34-
static const Normalizer2* TranslateToICUNormalizer(NormalizationForm normalizationForm)
35+
static const icu::Normalizer2* TranslateToICUNormalizer(NormalizationForm normalizationForm)
3536
{
3637
UErrorCode errorCode = U_ZERO_ERROR;
37-
const Normalizer2* normalizer;
38+
const icu::Normalizer2* normalizer;
3839

3940
switch (normalizationForm)
4041
{
4142
case NormalizationForm::C:
42-
normalizer = Normalizer2::getNFCInstance(errorCode);
43+
normalizer = icu::Normalizer2::getNFCInstance(errorCode);
4344
break;
4445
case NormalizationForm::D:
45-
normalizer = Normalizer2::getNFDInstance(errorCode);
46+
normalizer = icu::Normalizer2::getNFDInstance(errorCode);
4647
break;
4748
case NormalizationForm::KC:
48-
normalizer = Normalizer2::getNFKCInstance(errorCode);
49+
normalizer = icu::Normalizer2::getNFKCInstance(errorCode);
4950
break;
5051
case NormalizationForm::KD:
51-
normalizer = Normalizer2::getNFKDInstance(errorCode);
52+
normalizer = icu::Normalizer2::getNFKDInstance(errorCode);
5253
break;
5354
default:
5455
AssertMsg(false, "Unsupported normalization form");
@@ -157,13 +158,13 @@ namespace PlatformAgnostic
157158
return -1 * invalidIndex; // mimicking the behavior of Win32 NormalizeString
158159
}
159160

160-
const Normalizer2* normalizer = TranslateToICUNormalizer(normalizationForm);
161+
const icu::Normalizer2* normalizer = TranslateToICUNormalizer(normalizationForm);
161162
Assert(normalizer != nullptr);
162163

163-
const UnicodeString sourceUniStr((const UChar*) sourceString, sourceLength);
164+
const icu::UnicodeString sourceUniStr((const UChar*) sourceString, sourceLength);
164165

165166
UErrorCode errorCode = U_ZERO_ERROR;
166-
const UnicodeString destUniStr = normalizer->normalize(sourceUniStr, errorCode);
167+
const icu::UnicodeString destUniStr = normalizer->normalize(sourceUniStr, errorCode);
167168

168169
if (U_FAILURE(errorCode))
169170
{
@@ -208,10 +209,10 @@ namespace PlatformAgnostic
208209
return false;
209210
}
210211

211-
const Normalizer2* normalizer = TranslateToICUNormalizer(normalizationForm);
212+
const icu::Normalizer2* normalizer = TranslateToICUNormalizer(normalizationForm);
212213
Assert(normalizer != nullptr);
213214

214-
const UnicodeString testUniStr((const UChar*) testString, length);
215+
const icu::UnicodeString testUniStr((const UChar*) testString, length);
215216
bool isNormalized = normalizer->isNormalized(testUniStr, errorCode);
216217

217218
Assert(U_SUCCESS(errorCode));

lib/Runtime/PlatformAgnostic/RuntimePlatformAgnosticPch.h

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#define FALSE 0
3535
#endif
3636
#else
37+
#define U_USING_ICU_NAMESPACE 0
3738
#include <unicode/umachine.h>
3839
#endif
3940

0 commit comments

Comments
 (0)