(toOldUCharPtr(fWindowsLocaleName->getTerminatedBuffer()));
+ }
+
+ result = GetTimeFormatEx(localeName, tfFlags[fTimeStyle], st, NULL, buffer, STACK_BUFFER_SIZE);
if (result == 0) {
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
- int newLength = GetTimeFormatW(fLCID, tfFlags[fTimeStyle], st, NULL, NULL, 0);
+ int newLength = GetTimeFormatEx(localeName, tfFlags[fTimeStyle], st, NULL, NULL, 0);
buffer = NEW_ARRAY(wchar_t, newLength);
- GetDateFormatW(fLCID, tfFlags[fTimeStyle], st, NULL, buffer, newLength);
+
+ GetTimeFormatEx(localeName, tfFlags[fTimeStyle], st, NULL, buffer, newLength);
}
}
diff --git a/icu4c/source/i18n/windtfmt.h b/icu4c/source/i18n/windtfmt.h
index 492da150dc5..6d72a38e0cd 100644
--- a/icu4c/source/i18n/windtfmt.h
+++ b/icu4c/source/i18n/windtfmt.h
@@ -95,7 +95,7 @@ public:
*
* . Base* polymorphic_pointer = createPolymorphicObject();
* . if (polymorphic_pointer->getDynamicClassID() ==
- * . erived::getStaticClassID()) ...
+ * . derived::getStaticClassID()) ...
*
* @return The class ID for all objects of this class.
*/
@@ -124,9 +124,10 @@ private:
DateFormat::EStyle fTimeStyle;
DateFormat::EStyle fDateStyle;
Locale fLocale;
- int32_t fLCID;
UnicodeString fZoneID;
TIME_ZONE_INFORMATION *fTZI;
+
+ UnicodeString* fWindowsLocaleName; // Stores the equivalent Windows locale name.
};
U_NAMESPACE_END
diff --git a/icu4c/source/i18n/winnmfmt.cpp b/icu4c/source/i18n/winnmfmt.cpp
index 5b4a191747b..3f8271efaf0 100644
--- a/icu4c/source/i18n/winnmfmt.cpp
+++ b/icu4c/source/i18n/winnmfmt.cpp
@@ -28,7 +28,9 @@
#include "uassert.h"
#include "locmap.h"
+#ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
+#endif
# define VC_EXTRALEAN
# define NOUSER
# define NOSERVICE
@@ -58,43 +60,43 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(Win32NumberFormat)
* end in ";0" then the return value should be multiplied by 10.
* (e.g. "3" => 30, "3;2" => 320)
*/
-static UINT getGrouping(const char *grouping)
+static UINT getGrouping(const wchar_t *grouping)
{
UINT g = 0;
- const char *s;
+ const wchar_t *s;
- for (s = grouping; *s != '\0'; s += 1) {
- if (*s > '0' && *s < '9') {
- g = g * 10 + (*s - '0');
- } else if (*s != ';') {
+ for (s = grouping; *s != L'\0'; s += 1) {
+ if (*s > L'0' && *s < L'9') {
+ g = g * 10 + (*s - L'0');
+ } else if (*s != L';') {
break;
}
}
- if (*s != '0') {
+ if (*s != L'0') {
g *= 10;
}
return g;
}
-static void getNumberFormat(NUMBERFMTW *fmt, int32_t lcid)
+static void getNumberFormat(NUMBERFMTW *fmt, const wchar_t *windowsLocaleName)
{
- char buf[10];
+ wchar_t buf[10];
- GetLocaleInfoW(lcid, LOCALE_RETURN_NUMBER|LOCALE_IDIGITS, (LPWSTR) &fmt->NumDigits, sizeof(UINT));
- GetLocaleInfoW(lcid, LOCALE_RETURN_NUMBER|LOCALE_ILZERO, (LPWSTR) &fmt->LeadingZero, sizeof(UINT));
+ GetLocaleInfoEx(windowsLocaleName, LOCALE_RETURN_NUMBER|LOCALE_IDIGITS, (LPWSTR) &fmt->NumDigits, sizeof(UINT));
+ GetLocaleInfoEx(windowsLocaleName, LOCALE_RETURN_NUMBER|LOCALE_ILZERO, (LPWSTR) &fmt->LeadingZero, sizeof(UINT));
- GetLocaleInfoA(lcid, LOCALE_SGROUPING, buf, 10);
+ GetLocaleInfoEx(windowsLocaleName, LOCALE_SGROUPING, (LPWSTR)buf, 10);
fmt->Grouping = getGrouping(buf);
fmt->lpDecimalSep = NEW_ARRAY(wchar_t, 6);
- GetLocaleInfoW(lcid, LOCALE_SDECIMAL, fmt->lpDecimalSep, 6);
+ GetLocaleInfoEx(windowsLocaleName, LOCALE_SDECIMAL, fmt->lpDecimalSep, 6);
fmt->lpThousandSep = NEW_ARRAY(wchar_t, 6);
- GetLocaleInfoW(lcid, LOCALE_STHOUSAND, fmt->lpThousandSep, 6);
+ GetLocaleInfoEx(windowsLocaleName, LOCALE_STHOUSAND, fmt->lpThousandSep, 6);
- GetLocaleInfoW(lcid, LOCALE_RETURN_NUMBER|LOCALE_INEGNUMBER, (LPWSTR) &fmt->NegativeOrder, sizeof(UINT));
+ GetLocaleInfoEx(windowsLocaleName, LOCALE_RETURN_NUMBER|LOCALE_INEGNUMBER, (LPWSTR) &fmt->NegativeOrder, sizeof(UINT));
}
static void freeNumberFormat(NUMBERFMTW *fmt)
@@ -105,27 +107,27 @@ static void freeNumberFormat(NUMBERFMTW *fmt)
}
}
-static void getCurrencyFormat(CURRENCYFMTW *fmt, int32_t lcid)
+static void getCurrencyFormat(CURRENCYFMTW *fmt, const wchar_t *windowsLocaleName)
{
- char buf[10];
+ wchar_t buf[10];
- GetLocaleInfoW(lcid, LOCALE_RETURN_NUMBER|LOCALE_ICURRDIGITS, (LPWSTR) &fmt->NumDigits, sizeof(UINT));
- GetLocaleInfoW(lcid, LOCALE_RETURN_NUMBER|LOCALE_ILZERO, (LPWSTR) &fmt->LeadingZero, sizeof(UINT));
+ GetLocaleInfoEx(windowsLocaleName, LOCALE_RETURN_NUMBER|LOCALE_ICURRDIGITS, (LPWSTR) &fmt->NumDigits, sizeof(UINT));
+ GetLocaleInfoEx(windowsLocaleName, LOCALE_RETURN_NUMBER|LOCALE_ILZERO, (LPWSTR) &fmt->LeadingZero, sizeof(UINT));
- GetLocaleInfoA(lcid, LOCALE_SMONGROUPING, buf, sizeof(buf));
+ GetLocaleInfoEx(windowsLocaleName, LOCALE_SMONGROUPING, (LPWSTR)buf, sizeof(buf));
fmt->Grouping = getGrouping(buf);
fmt->lpDecimalSep = NEW_ARRAY(wchar_t, 6);
- GetLocaleInfoW(lcid, LOCALE_SMONDECIMALSEP, fmt->lpDecimalSep, 6);
+ GetLocaleInfoEx(windowsLocaleName, LOCALE_SMONDECIMALSEP, fmt->lpDecimalSep, 6);
fmt->lpThousandSep = NEW_ARRAY(wchar_t, 6);
- GetLocaleInfoW(lcid, LOCALE_SMONTHOUSANDSEP, fmt->lpThousandSep, 6);
+ GetLocaleInfoEx(windowsLocaleName, LOCALE_SMONTHOUSANDSEP, fmt->lpThousandSep, 6);
- GetLocaleInfoW(lcid, LOCALE_RETURN_NUMBER|LOCALE_INEGCURR, (LPWSTR) &fmt->NegativeOrder, sizeof(UINT));
- GetLocaleInfoW(lcid, LOCALE_RETURN_NUMBER|LOCALE_ICURRENCY, (LPWSTR) &fmt->PositiveOrder, sizeof(UINT));
+ GetLocaleInfoEx(windowsLocaleName, LOCALE_RETURN_NUMBER|LOCALE_INEGCURR, (LPWSTR) &fmt->NegativeOrder, sizeof(UINT));
+ GetLocaleInfoEx(windowsLocaleName, LOCALE_RETURN_NUMBER|LOCALE_ICURRENCY, (LPWSTR) &fmt->PositiveOrder, sizeof(UINT));
fmt->lpCurrencySymbol = NEW_ARRAY(wchar_t, 8);
- GetLocaleInfoW(lcid, LOCALE_SCURRENCY, (LPWSTR) fmt->lpCurrencySymbol, 8);
+ GetLocaleInfoEx(windowsLocaleName, LOCALE_SCURRENCY, (LPWSTR) fmt->lpCurrencySymbol, 8);
}
static void freeCurrencyFormat(CURRENCYFMTW *fmt)
@@ -137,12 +139,84 @@ static void freeCurrencyFormat(CURRENCYFMTW *fmt)
}
}
+// TODO: This is copied in both winnmfmt.cpp and windtfmt.cpp, but really should
+// be factored out into a common helper for both.
+static UErrorCode GetEquivalentWindowsLocaleName(const Locale& locale, UnicodeString** buffer)
+{
+ UErrorCode status = U_ZERO_ERROR;
+ char asciiBCP47Tag[LOCALE_NAME_MAX_LENGTH] = {};
+
+ // Convert from names like "en_CA" and "de_DE@collation=phonebook" to "en-CA" and "de-DE-u-co-phonebk".
+ int32_t length = uloc_toLanguageTag(locale.getName(), asciiBCP47Tag, UPRV_LENGTHOF(asciiBCP47Tag), FALSE, &status);
+
+ if (U_SUCCESS(status))
+ {
+ // Need it to be UTF-16, not 8-bit
+ // TODO: This seems like a good thing for a helper
+ wchar_t bcp47Tag[LOCALE_NAME_MAX_LENGTH] = {};
+ int i;
+ for (i = 0; i < UPRV_LENGTHOF(bcp47Tag); i++)
+ {
+ if (asciiBCP47Tag[i] == '\0')
+ {
+ break;
+ }
+ else
+ {
+ // normally just copy the character
+ bcp47Tag[i] = static_cast(asciiBCP47Tag[i]);
+ }
+ }
+
+ // Ensure it's null terminated
+ if (i < (UPRV_LENGTHOF(bcp47Tag) - 1))
+ {
+ bcp47Tag[i] = L'\0';
+ }
+ else
+ {
+ // Ran out of room.
+ bcp47Tag[UPRV_LENGTHOF(bcp47Tag) - 1] = L'\0';
+ }
+
+
+ wchar_t windowsLocaleName[LOCALE_NAME_MAX_LENGTH] = {};
+
+ // Note: On Windows versions below 10, there is no support for locale name aliases.
+ // This means that it will fail for locales where ICU has a completely different
+ // name (like ku vs ckb), and it will also not work for alternate sort locale
+ // names like "de-DE-u-co-phonebk".
+
+ // TODO: We could add some sort of exception table for cases like ku vs ckb.
+
+ int length = ResolveLocaleName(bcp47Tag, windowsLocaleName, UPRV_LENGTHOF(windowsLocaleName));
+
+ if (length > 0)
+ {
+ *buffer = new UnicodeString(windowsLocaleName);
+ }
+ else
+ {
+ status = U_UNSUPPORTED_ERROR;
+ }
+ }
+ return status;
+}
+
Win32NumberFormat::Win32NumberFormat(const Locale &locale, UBool currency, UErrorCode &status)
- : NumberFormat(), fCurrency(currency), fFormatInfo(NULL), fFractionDigitsSet(FALSE)
+ : NumberFormat(), fCurrency(currency), fFormatInfo(NULL), fFractionDigitsSet(FALSE), fWindowsLocaleName(nullptr)
{
if (!U_FAILURE(status)) {
fLCID = locale.getLCID();
+ GetEquivalentWindowsLocaleName(locale, &fWindowsLocaleName);
+ // Note: In the previous code, it would look up the LCID for the locale, and if
+ // the locale was not recognized then it would get an LCID of 0, which is a
+ // synonym for LOCALE_USER_DEFAULT on Windows.
+ // If the above method fails, then fWindowsLocaleName will remain as nullptr, and
+ // then we will pass nullptr to API GetLocaleInfoEx, which is the same as passing
+ // LOCALE_USER_DEFAULT.
+
// Resolve actual locale to be used later
UErrorCode tmpsts = U_ZERO_ERROR;
char tmpLocID[ULOC_FULLNAME_CAPACITY];
@@ -152,12 +226,19 @@ Win32NumberFormat::Win32NumberFormat(const Locale &locale, UBool currency, UErro
fLocale = Locale((const char*)tmpLocID);
}
+ const wchar_t *localeName = nullptr;
+
+ if (fWindowsLocaleName != nullptr)
+ {
+ localeName = reinterpret_cast(toOldUCharPtr(fWindowsLocaleName->getTerminatedBuffer()));
+ }
+
fFormatInfo = (FormatInfo*)uprv_malloc(sizeof(FormatInfo));
if (fCurrency) {
- getCurrencyFormat(&fFormatInfo->currency, fLCID);
+ getCurrencyFormat(&fFormatInfo->currency, localeName);
} else {
- getNumberFormat(&fFormatInfo->number, fLCID);
+ getNumberFormat(&fFormatInfo->number, localeName);
}
}
}
@@ -182,6 +263,7 @@ Win32NumberFormat::~Win32NumberFormat()
uprv_free(fFormatInfo);
}
+ delete fWindowsLocaleName;
}
Win32NumberFormat &Win32NumberFormat::operator=(const Win32NumberFormat &other)
@@ -192,13 +274,21 @@ Win32NumberFormat &Win32NumberFormat::operator=(const Win32NumberFormat &other)
this->fLocale = other.fLocale;
this->fLCID = other.fLCID;
this->fFractionDigitsSet = other.fFractionDigitsSet;
+ this->fWindowsLocaleName = other.fWindowsLocaleName == NULL ? NULL : new UnicodeString(*other.fWindowsLocaleName);
+
+ const wchar_t *localeName = nullptr;
+
+ if (fWindowsLocaleName != nullptr)
+ {
+ localeName = reinterpret_cast(toOldUCharPtr(fWindowsLocaleName->getTerminatedBuffer()));
+ }
if (fCurrency) {
freeCurrencyFormat(&fFormatInfo->currency);
- getCurrencyFormat(&fFormatInfo->currency, fLCID);
+ getCurrencyFormat(&fFormatInfo->currency, localeName);
} else {
freeNumberFormat(&fFormatInfo->number);
- getNumberFormat(&fFormatInfo->number, fLCID);
+ getNumberFormat(&fFormatInfo->number, localeName);
}
return *this;
@@ -299,6 +389,13 @@ UnicodeString &Win32NumberFormat::format(int32_t numDigits, UnicodeString &appen
formatInfo = *fFormatInfo;
buffer[0] = 0x0000;
+ const wchar_t *localeName = nullptr;
+
+ if (fWindowsLocaleName != nullptr)
+ {
+ localeName = reinterpret_cast(toOldUCharPtr(fWindowsLocaleName->getTerminatedBuffer()));
+ }
+
if (fCurrency) {
if (fFractionDigitsSet) {
formatInfo.currency.NumDigits = (UINT) numDigits;
@@ -308,17 +405,17 @@ UnicodeString &Win32NumberFormat::format(int32_t numDigits, UnicodeString &appen
formatInfo.currency.Grouping = 0;
}
- result = GetCurrencyFormatW(fLCID, 0, nBuffer, &formatInfo.currency, buffer, STACK_BUFFER_SIZE);
+ result = GetCurrencyFormatEx(localeName, 0, nBuffer, &formatInfo.currency, buffer, STACK_BUFFER_SIZE);
if (result == 0) {
DWORD lastError = GetLastError();
if (lastError == ERROR_INSUFFICIENT_BUFFER) {
- int newLength = GetCurrencyFormatW(fLCID, 0, nBuffer, &formatInfo.currency, NULL, 0);
+ int newLength = GetCurrencyFormatEx(localeName, 0, nBuffer, &formatInfo.currency, NULL, 0);
buffer = NEW_ARRAY(wchar_t, newLength);
buffer[0] = 0x0000;
- GetCurrencyFormatW(fLCID, 0, nBuffer, &formatInfo.currency, buffer, newLength);
+ GetCurrencyFormatEx(localeName, 0, nBuffer, &formatInfo.currency, buffer, newLength);
}
}
} else {
@@ -330,15 +427,15 @@ UnicodeString &Win32NumberFormat::format(int32_t numDigits, UnicodeString &appen
formatInfo.number.Grouping = 0;
}
- result = GetNumberFormatW(fLCID, 0, nBuffer, &formatInfo.number, buffer, STACK_BUFFER_SIZE);
+ result = GetNumberFormatEx(localeName, 0, nBuffer, &formatInfo.number, buffer, STACK_BUFFER_SIZE);
if (result == 0) {
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
- int newLength = GetNumberFormatW(fLCID, 0, nBuffer, &formatInfo.number, NULL, 0);
+ int newLength = GetNumberFormatEx(localeName, 0, nBuffer, &formatInfo.number, NULL, 0);
buffer = NEW_ARRAY(wchar_t, newLength);
buffer[0] = 0x0000;
- GetNumberFormatW(fLCID, 0, nBuffer, &formatInfo.number, buffer, newLength);
+ GetNumberFormatEx(localeName, 0, nBuffer, &formatInfo.number, buffer, newLength);
}
}
}
diff --git a/icu4c/source/i18n/winnmfmt.h b/icu4c/source/i18n/winnmfmt.h
index 1b1977152e9..6139c1ff68a 100644
--- a/icu4c/source/i18n/winnmfmt.h
+++ b/icu4c/source/i18n/winnmfmt.h
@@ -128,7 +128,7 @@ public:
*
* . Base* polymorphic_pointer = createPolymorphicObject();
* . if (polymorphic_pointer->getDynamicClassID() ==
- * . erived::getStaticClassID()) ...
+ * . derived::getStaticClassID()) ...
*
* @return The class ID for all objects of this class.
*/
@@ -155,6 +155,7 @@ private:
FormatInfo *fFormatInfo;
UBool fFractionDigitsSet;
+ UnicodeString* fWindowsLocaleName; // Stores the equivalent Windows locale name.
};
U_NAMESPACE_END
diff --git a/icu4c/source/i18n/wintzimpl.cpp b/icu4c/source/i18n/wintzimpl.cpp
index 78629e5f485..5a29f29a77a 100644
--- a/icu4c/source/i18n/wintzimpl.cpp
+++ b/icu4c/source/i18n/wintzimpl.cpp
@@ -24,7 +24,9 @@
#include "uassert.h"
#include "cmemory.h"
+#ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
+#endif
# define VC_EXTRALEAN
# define NOUSER
# define NOSERVICE
diff --git a/icu4c/source/test/intltest/winutil.cpp b/icu4c/source/test/intltest/winutil.cpp
index 1f998e33cbf..87b2d402e83 100644
--- a/icu4c/source/test/intltest/winutil.cpp
+++ b/icu4c/source/test/intltest/winutil.cpp
@@ -36,6 +36,7 @@ static Win32Utilities::LCIDRecord *lcidRecords = NULL;
static int32_t lcidCount = 0;
static int32_t lcidMax = 0;
+// TODO: Note that this test will skip locale names and only hit locales with assigned LCIDs
BOOL CALLBACK EnumLocalesProc(LPSTR lpLocaleString)
{
char localeID[ULOC_FULLNAME_CAPACITY];
@@ -70,6 +71,7 @@ BOOL CALLBACK EnumLocalesProc(LPSTR lpLocaleString)
return TRUE;
}
+// TODO: Note that this test will skip locale names and only hit locales with assigned LCIDs
Win32Utilities::LCIDRecord *Win32Utilities::getLocales(int32_t &localeCount)
{
LCIDRecord *result;
diff --git a/icu4c/source/tools/pkgdata/pkgdata.cpp b/icu4c/source/tools/pkgdata/pkgdata.cpp
index 432552160b6..ffcf459c349 100644
--- a/icu4c/source/tools/pkgdata/pkgdata.cpp
+++ b/icu4c/source/tools/pkgdata/pkgdata.cpp
@@ -121,7 +121,9 @@ enum {
LIBNAME,
QUIET,
WITHOUT_ASSEMBLY,
- PDS_BUILD
+ PDS_BUILD,
+ UWP_BUILD,
+ UWP_ARM_BUILD
};
/* This sets the modes that are available */
@@ -163,7 +165,9 @@ static UOption options[]={
/*18*/ UOPTION_DEF( "libname", 'L', UOPT_REQUIRES_ARG),
/*19*/ UOPTION_DEF( "quiet", 'q', UOPT_NO_ARG),
/*20*/ UOPTION_DEF( "without-assembly", 'w', UOPT_NO_ARG),
- /*21*/ UOPTION_DEF( "zos-pds-build", 'z', UOPT_NO_ARG)
+ /*21*/ UOPTION_DEF("zos-pds-build", 'z', UOPT_NO_ARG),
+ /*22*/ UOPTION_DEF("windows-uwp-build", 'u', UOPT_NO_ARG),
+ /*23*/ UOPTION_DEF("windows-uwp-arm-build", 'a', UOPT_NO_ARG)
};
/* This enum and the following char array should be kept in sync. */
@@ -250,9 +254,11 @@ const char options_help[][320]={
"Specify a version when packaging in dll or static mode",
"Add package to all file names if not present",
"Library name to build (if different than package name)",
- "Quite mode. (e.g. Do not output a readme file for static libraries)",
+ "Quiet mode. (e.g. Do not output a readme file for static libraries)",
"Build the data without assembly code",
- "Build PDS dataset (zOS build only)"
+ "Build PDS dataset (zOS build only)",
+ "Build for Universal Windows Platform (Windows build only)",
+ "Set DLL machine type for UWP to target windows ARM (Windows UWP build only)"
};
const char *progname = "PKGDATA";
@@ -1751,7 +1757,14 @@ static int32_t pkg_createWithoutAssemblyCode(UPKGOptions *o, const char *targetD
#ifdef WINDOWS_WITH_MSVC
#define LINK_CMD "link.exe /nologo /release /out:"
-#define LINK_FLAGS "/DLL /NOENTRY /MANIFEST:NO /base:0x4ad00000 /implib:"
+#define LINK_FLAGS "/DLL /NOENTRY /MANIFEST:NO /implib:"
+#ifdef _WIN64
+#define LINK_EXTRA_UWP_FLAGS "/NXCOMPAT /DYNAMICBASE /APPCONTAINER "
+#else
+#define LINK_EXTRA_UWP_FLAGS "/NXCOMPAT /SAFESEH /DYNAMICBASE /APPCONTAINER /MACHINE:X86"
+#endif
+#define LINK_EXTRA_UWP_FLAGS_ARM "/NXCOMPAT /DYNAMICBASE /APPCONTAINER /MACHINE:ARM"
+#define LINK_EXTRA_NO_UWP_FLAGS "/base:0x4ad00000 "
#define LIB_CMD "LIB.exe /nologo /out:"
#define LIB_FILE "icudt.lib"
#define LIB_EXT UDATA_LIB_SUFFIX
@@ -1831,14 +1844,33 @@ static int32_t pkg_createWindowsDLL(const char mode, const char *gencFilePath, U
return 0;
}
- sprintf(cmd, "%s\"%s\" %s\"%s\" \"%s\" %s",
- LINK_CMD,
- dllFilePath,
- LINK_FLAGS,
- libFilePath,
- gencFilePath,
- resFilePath
- );
+ char *extraFlags = "";
+#ifdef WINDOWS_WITH_MSVC
+ if (options[UWP_BUILD].doesOccur)
+ {
+ if (options[UWP_ARM_BUILD].doesOccur)
+ {
+ extraFlags = LINK_EXTRA_UWP_FLAGS_ARM;
+ }
+ else
+ {
+ extraFlags = LINK_EXTRA_UWP_FLAGS;
+ }
+ }
+ else
+ {
+ extraFlags = LINK_EXTRA_NO_UWP_FLAGS;
+ }
+#endif
+ sprintf(cmd, "%s\"%s\" %s %s\"%s\" \"%s\" %s",
+ LINK_CMD,
+ dllFilePath,
+ extraFlags,
+ LINK_FLAGS,
+ libFilePath,
+ gencFilePath,
+ resFilePath
+ );
}
result = runCommand(cmd, TRUE);
diff --git a/icu4c/source/tools/toolutil/pkg_genc.cpp b/icu4c/source/tools/toolutil/pkg_genc.cpp
index 9ff6ce56df8..e4d11956bdc 100644
--- a/icu4c/source/tools/toolutil/pkg_genc.cpp
+++ b/icu4c/source/tools/toolutil/pkg_genc.cpp
@@ -687,12 +687,19 @@ getArchitecture(uint16_t *pCPU, uint16_t *pBits, UBool *pIsBigEndian, const char
/* _M_IA64 should be defined in windows.h */
# if defined(_M_IA64)
*pCPU=IMAGE_FILE_MACHINE_IA64;
+ *pBits = 64;
# elif defined(_M_AMD64)
- *pCPU=IMAGE_FILE_MACHINE_AMD64;
+// link.exe does not really care about the .obj machine type and this will
+// allow us to build a dll for both ARM & x64 with an amd64 built tool
+// ARM is same as x64 except for first 2 bytes of object file
+ *pCPU = IMAGE_FILE_MACHINE_UNKNOWN;
+ // *pCPU = IMAGE_FILE_MACHINE_ARMNT; // If we wanted to be explicit
+ // *pCPU = IMAGE_FILE_MACHINE_AMD64; // We would use one of these names
+ *pBits = 64; // Doesn't seem to be used for anything interesting?
# else
- *pCPU=IMAGE_FILE_MACHINE_I386;
+ *pCPU=IMAGE_FILE_MACHINE_I386; // We would use one of these names
+ *pBits = 32;
# endif
- *pBits= *pCPU==IMAGE_FILE_MACHINE_I386 ? 32 : 64;
*pIsBigEndian=FALSE;
#else
# error "Unknown platform for CAN_GENERATE_OBJECTS."
@@ -1030,7 +1037,14 @@ writeObjectCode(const char *filename, const char *destdir, const char *optEntryP
/* deal with options, files and the entry point name */
getArchitecture(&cpu, &bits, &makeBigEndian, optMatchArch);
- printf("genccode: --match-arch cpu=%hu bits=%hu big-endian=%d\n", cpu, bits, makeBigEndian);
+ if (optMatchArch)
+ {
+ printf("genccode: --match-arch cpu=%hu bits=%hu big-endian=%d\n", cpu, bits, makeBigEndian);
+ }
+ else
+ {
+ printf("genccode: using architecture cpu=%hu bits=%hu big-endian=%d\n", cpu, bits, makeBigEndian);
+ }
#if U_PLATFORM_HAS_WIN32_API
if(cpu==IMAGE_FILE_MACHINE_I386) {
entryOffset=1;
--
2.40.0