*/
#include <stddef.h>
+/*
+ * U_USE_CHAR16_T
+ * When defined, force use of char16_t for UChar.
+ * Note: char16_t is expected to become the default and required in the future,
+ * and this option will be removed.
+ * @internal
+ */
+#ifdef U_USE_CHAR16_T
+#ifdef UCHAR_TYPE
+#undef UCHAR_TYPE
+#endif
+#define UCHAR_TYPE char16_t
+
+/*
+ * In plain C, <uchar.h> is needed for the definition of char16_t
+ */
+#ifndef __cplusplus
+#include <uchar.h>
+#endif
+#endif
+
/*==========================================================================*/
/* For C wrappers, we use the symbol U_STABLE. */
/* This works properly if the includer is C or C++. */
*pDestLength = srcLength;
}
- u_terminateUChars(dest,destCapacity,srcLength,pErrorCode);
+ u_terminateUChars((UChar *)dest,destCapacity,srcLength,pErrorCode);
return dest;
#ifdef U_WCHAR_IS_UTF16
/* wchar_t is UTF-16 just do a memcpy */
if(srcLength == -1){
- srcLength = u_strlen(src);
+ srcLength = u_strlen((const UChar *)src);
}
if(0 < srcLength && srcLength <= destCapacity){
uprv_memcpy(dest,src,srcLength*U_SIZEOF_UCHAR);
u_strlen(const UChar *s)
{
#if U_SIZEOF_WCHAR_T == U_SIZEOF_UCHAR
- return (int32_t)uprv_wcslen(s);
+ return (int32_t)uprv_wcslen((const wchar_t *)s);
#else
const UChar *t = s;
while(*t != 0) {
void Win32DateFormat::formatDate(const SYSTEMTIME *st, UnicodeString &appendTo) const
{
int result;
- UChar stackBuffer[STACK_BUFFER_SIZE];
- UChar *buffer = stackBuffer;
+ wchar_t stackBuffer[STACK_BUFFER_SIZE];
+ wchar_t *buffer = stackBuffer;
result = GetDateFormatW(fLCID, dfFlags[fDateStyle - kDateOffset], st, NULL, buffer, STACK_BUFFER_SIZE);
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
int newLength = GetDateFormatW(fLCID, dfFlags[fDateStyle - kDateOffset], st, NULL, NULL, 0);
- buffer = NEW_ARRAY(UChar, newLength);
+ buffer = NEW_ARRAY(wchar_t, newLength);
GetDateFormatW(fLCID, dfFlags[fDateStyle - kDateOffset], st, NULL, buffer, newLength);
}
}
- appendTo.append(buffer, (int32_t) wcslen(buffer));
+ appendTo.append((const UChar *)buffer, (int32_t) wcslen(buffer));
if (buffer != stackBuffer) {
DELETE_ARRAY(buffer);
void Win32DateFormat::formatTime(const SYSTEMTIME *st, UnicodeString &appendTo) const
{
int result;
- UChar stackBuffer[STACK_BUFFER_SIZE];
- UChar *buffer = stackBuffer;
+ wchar_t stackBuffer[STACK_BUFFER_SIZE];
+ wchar_t *buffer = stackBuffer;
result = GetTimeFormatW(fLCID, tfFlags[fTimeStyle], st, NULL, buffer, STACK_BUFFER_SIZE);
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
int newLength = GetTimeFormatW(fLCID, tfFlags[fTimeStyle], st, NULL, NULL, 0);
- buffer = NEW_ARRAY(UChar, newLength);
+ buffer = NEW_ARRAY(wchar_t, newLength);
GetDateFormatW(fLCID, tfFlags[fTimeStyle], st, NULL, buffer, newLength);
}
}
- appendTo.append(buffer, (int32_t) wcslen(buffer));
+ appendTo.append((const UChar *)buffer, (int32_t) wcslen(buffer));
if (buffer != stackBuffer) {
DELETE_ARRAY(buffer);
GetLocaleInfoA(lcid, LOCALE_SGROUPING, buf, 10);
fmt->Grouping = getGrouping(buf);
- fmt->lpDecimalSep = NEW_ARRAY(UChar, 6);
+ fmt->lpDecimalSep = NEW_ARRAY(wchar_t, 6);
GetLocaleInfoW(lcid, LOCALE_SDECIMAL, fmt->lpDecimalSep, 6);
- fmt->lpThousandSep = NEW_ARRAY(UChar, 6);
+ fmt->lpThousandSep = NEW_ARRAY(wchar_t, 6);
GetLocaleInfoW(lcid, LOCALE_STHOUSAND, fmt->lpThousandSep, 6);
GetLocaleInfoW(lcid, LOCALE_RETURN_NUMBER|LOCALE_INEGNUMBER, (LPWSTR) &fmt->NegativeOrder, sizeof(UINT));
GetLocaleInfoA(lcid, LOCALE_SMONGROUPING, buf, sizeof(buf));
fmt->Grouping = getGrouping(buf);
- fmt->lpDecimalSep = NEW_ARRAY(UChar, 6);
+ fmt->lpDecimalSep = NEW_ARRAY(wchar_t, 6);
GetLocaleInfoW(lcid, LOCALE_SMONDECIMALSEP, fmt->lpDecimalSep, 6);
- fmt->lpThousandSep = NEW_ARRAY(UChar, 6);
+ fmt->lpThousandSep = NEW_ARRAY(wchar_t, 6);
GetLocaleInfoW(lcid, 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));
- fmt->lpCurrencySymbol = NEW_ARRAY(UChar, 8);
+ fmt->lpCurrencySymbol = NEW_ARRAY(wchar_t, 8);
GetLocaleInfoW(lcid, LOCALE_SCURRENCY, (LPWSTR) fmt->lpCurrencySymbol, 8);
}
}
}
- UChar stackBuffer[STACK_BUFFER_SIZE];
- UChar *buffer = stackBuffer;
+ wchar_t stackBuffer[STACK_BUFFER_SIZE];
+ wchar_t *buffer = stackBuffer;
FormatInfo formatInfo;
formatInfo = *fFormatInfo;
if (lastError == ERROR_INSUFFICIENT_BUFFER) {
int newLength = GetCurrencyFormatW(fLCID, 0, nBuffer, &formatInfo.currency, NULL, 0);
- buffer = NEW_ARRAY(UChar, newLength);
+ buffer = NEW_ARRAY(wchar_t, newLength);
buffer[0] = 0x0000;
GetCurrencyFormatW(fLCID, 0, nBuffer, &formatInfo.currency, buffer, newLength);
}
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
int newLength = GetNumberFormatW(fLCID, 0, nBuffer, &formatInfo.number, NULL, 0);
- buffer = NEW_ARRAY(UChar, newLength);
+ buffer = NEW_ARRAY(wchar_t, newLength);
buffer[0] = 0x0000;
GetNumberFormatW(fLCID, 0, nBuffer, &formatInfo.number, buffer, newLength);
}
}
}
- appendTo.append(buffer, (int32_t) wcslen(buffer));
+ appendTo.append((UChar *)buffer, (int32_t) wcslen(buffer));
if (buffer != stackBuffer) {
DELETE_ARRAY(buffer);
wdf->format(icuNow, udBuffer);
wtf->format(icuNow, utBuffer);
- if (ubBuffer.indexOf(wdBuffer, wdLength - 1, 0) < 0) {
+ if (ubBuffer.indexOf((const UChar *)wdBuffer, wdLength - 1, 0) < 0) {
UnicodeString baseName(wlocale.getBaseName());
- UnicodeString expected(wdBuffer);
+ UnicodeString expected((const UChar *)wdBuffer);
log->errln("DateTime format error for locale " + baseName + ": expected date \"" + expected +
"\" got \"" + ubBuffer + "\"");
}
- if (ubBuffer.indexOf(wtBuffer, wtLength - 1, 0) < 0) {
+ if (ubBuffer.indexOf((const UChar *)wtBuffer, wtLength - 1, 0) < 0) {
UnicodeString baseName(wlocale.getBaseName());
- UnicodeString expected(wtBuffer);
+ UnicodeString expected((const UChar *)wtBuffer);
log->errln("DateTime format error for locale " + baseName + ": expected time \"" + expected +
"\" got \"" + ubBuffer + "\"");
}
- if (udBuffer.compare(wdBuffer) != 0) {
+ if (udBuffer.compare((const UChar *)wdBuffer) != 0) {
UnicodeString baseName(wlocale.getBaseName());
- UnicodeString expected(wdBuffer);
+ UnicodeString expected((const UChar *)wdBuffer);
log->errln("Date format error for locale " + baseName + ": expected \"" + expected +
"\" got \"" + udBuffer + "\"");
}
- if (utBuffer.compare(wtBuffer) != 0) {
+ if (utBuffer.compare((const UChar *)wtBuffer) != 0) {
UnicodeString baseName(wlocale.getBaseName());
- UnicodeString expected(wtBuffer);
+ UnicodeString expected((const UChar *)wtBuffer);
log->errln("Time format error for locale " + baseName + ": expected \"" + expected +
"\" got \"" + utBuffer + "\"");
if (lastError == ERROR_INSUFFICIENT_BUFFER) {
int newLength = GetCurrencyFormatW(lcid, 0, nBuffer, NULL, NULL, 0);
- buffer = NEW_ARRAY(UChar, newLength);
+ buffer = NEW_ARRAY(wchar_t, newLength);
buffer[0] = 0x0000;
GetCurrencyFormatW(lcid, 0, nBuffer, NULL, buffer, newLength);
}
if (lastError == ERROR_INSUFFICIENT_BUFFER) {
int newLength = GetNumberFormatW(lcid, 0, nBuffer, NULL, NULL, 0);
- buffer = NEW_ARRAY(UChar, newLength);
+ buffer = NEW_ARRAY(wchar_t, newLength);
buffer[0] = 0x0000;
GetNumberFormatW(lcid, 0, nBuffer, NULL, buffer, newLength);
}
}
}
- appendTo.append(buffer, (int32_t) wcslen(buffer));
+ appendTo.append((const UChar *)buffer, (int32_t) wcslen(buffer));
if (buffer != stackBuffer) {
DELETE_ARRAY(buffer);