@@ -249,10 +249,10 @@ GetMonthDayPattern
249
249
250
250
Gets the Month-Day DateTime pattern for the specified locale.
251
251
*/
252
- CalendarDataResult GetMonthDayPattern (Locale& locale, UChar* sMonthDay , int32_t stringCapacity)
252
+ CalendarDataResult GetMonthDayPattern (const char * locale, UChar* sMonthDay , int32_t stringCapacity)
253
253
{
254
254
UErrorCode err = U_ZERO_ERROR;
255
- UDateTimePatternGenerator* pGenerator = udatpg_open (locale. getName () , &err);
255
+ UDateTimePatternGenerator* pGenerator = udatpg_open (locale, &err);
256
256
UDateTimePatternGeneratorHolder generatorHolder (pGenerator, err);
257
257
258
258
if (U_FAILURE (err))
@@ -270,10 +270,10 @@ GetNativeCalendarName
270
270
Gets the native calendar name.
271
271
*/
272
272
CalendarDataResult
273
- GetNativeCalendarName (Locale& locale, CalendarId calendarId, UChar* nativeName, int32_t stringCapacity)
273
+ GetNativeCalendarName (const char * locale, CalendarId calendarId, UChar* nativeName, int32_t stringCapacity)
274
274
{
275
275
UErrorCode err = U_ZERO_ERROR;
276
- ULocaleDisplayNames* pDisplayNames = uldn_open (locale. getName () , ULDN_STANDARD_NAMES, &err);
276
+ ULocaleDisplayNames* pDisplayNames = uldn_open (locale, ULDN_STANDARD_NAMES, &err);
277
277
ULocaleDisplayNamesHolder displayNamesHolder (pDisplayNames, err);
278
278
279
279
uldn_keyValueDisplayName (pDisplayNames, " calendar" , GetCalendarName (calendarId), nativeName, stringCapacity, &err);
@@ -298,9 +298,9 @@ extern "C" CalendarDataResult GetCalendarInfo(
298
298
switch (dataType)
299
299
{
300
300
case NativeName:
301
- return GetNativeCalendarName (locale, calendarId, result, resultCapacity);
301
+ return GetNativeCalendarName (locale. getName () , calendarId, result, resultCapacity);
302
302
case MonthDay:
303
- return GetMonthDayPattern (locale, result, resultCapacity);
303
+ return GetMonthDayPattern (locale. getName () , result, resultCapacity);
304
304
default :
305
305
assert (false );
306
306
return UnknownError;
@@ -314,13 +314,13 @@ InvokeCallbackForDatePattern
314
314
Gets the ICU date pattern for the specified locale and EStyle and invokes the
315
315
callback with the result.
316
316
*/
317
- bool InvokeCallbackForDatePattern (Locale& locale,
317
+ bool InvokeCallbackForDatePattern (const char * locale,
318
318
UDateFormatStyle style,
319
319
EnumCalendarInfoCallback callback,
320
320
const void * context)
321
321
{
322
322
UErrorCode err = U_ZERO_ERROR;
323
- UDateFormat* pFormat = udat_open (UDAT_NONE, style, locale. getName () , nullptr , 0 , nullptr , 0 , &err);
323
+ UDateFormat* pFormat = udat_open (UDAT_NONE, style, locale, nullptr , 0 , nullptr , 0 , &err);
324
324
UDateFormatHolder formatHolder (pFormat, err);
325
325
326
326
if (U_FAILURE (err))
@@ -353,13 +353,13 @@ InvokeCallbackForDateTimePattern
353
353
Gets the DateTime pattern for the specified skeleton and invokes the callback
354
354
with the retrieved value.
355
355
*/
356
- bool InvokeCallbackForDateTimePattern (Locale& locale,
356
+ bool InvokeCallbackForDateTimePattern (const char * locale,
357
357
const UChar* patternSkeleton,
358
358
EnumCalendarInfoCallback callback,
359
359
const void * context)
360
360
{
361
361
UErrorCode err = U_ZERO_ERROR;
362
- UDateTimePatternGenerator* pGenerator = udatpg_open (locale. getName () , &err);
362
+ UDateTimePatternGenerator* pGenerator = udatpg_open (locale, &err);
363
363
UDateTimePatternGeneratorHolder generatorHolder (pGenerator, err);
364
364
365
365
if (U_FAILURE (err))
@@ -394,22 +394,22 @@ EnumSymbols
394
394
Enumerates of of the symbols of a type for a locale and calendar and invokes a callback
395
395
for each value.
396
396
*/
397
- bool EnumSymbols (Locale& locale,
397
+ bool EnumSymbols (const char * locale,
398
398
CalendarId calendarId,
399
399
UDateFormatSymbolType type,
400
400
int32_t startIndex,
401
401
EnumCalendarInfoCallback callback,
402
402
const void * context)
403
403
{
404
404
UErrorCode err = U_ZERO_ERROR;
405
- UDateFormat* pFormat = udat_open (UDAT_DEFAULT, UDAT_DEFAULT, locale. getName () , nullptr , 0 , nullptr , 0 , &err);
405
+ UDateFormat* pFormat = udat_open (UDAT_DEFAULT, UDAT_DEFAULT, locale, nullptr , 0 , nullptr , 0 , &err);
406
406
UDateFormatHolder formatHolder (pFormat, err);
407
407
408
408
if (U_FAILURE (err))
409
409
return false ;
410
410
411
411
char localeWithCalendarName[ULOC_FULLNAME_CAPACITY];
412
- strncpy (localeWithCalendarName, locale. getName () , ULOC_FULLNAME_CAPACITY);
412
+ strncpy (localeWithCalendarName, locale, ULOC_FULLNAME_CAPACITY);
413
413
uloc_setKeywordValue (" calendar" , GetCalendarName (calendarId), localeWithCalendarName, ULOC_FULLNAME_CAPACITY, &err);
414
414
415
415
if (U_FAILURE (err))
@@ -471,7 +471,10 @@ EnumAbbrevEraNames
471
471
Enumerates all the abbreviated era names of the specified locale and calendar, invoking the
472
472
callback function for each era name.
473
473
*/
474
- bool EnumAbbrevEraNames (Locale& locale, CalendarId calendarId, EnumCalendarInfoCallback callback, const void * context)
474
+ bool EnumAbbrevEraNames (const char * locale,
475
+ CalendarId calendarId,
476
+ EnumCalendarInfoCallback callback,
477
+ const void * context)
475
478
{
476
479
// The C-API for ICU provides no way to get at the abbreviated era names for a calendar (so we can't use EnumSymbols
477
480
// here). Instead we will try to walk the ICU resource tables directly and fall back to regular era names if can't
@@ -482,7 +485,7 @@ bool EnumAbbrevEraNames(Locale& locale, CalendarId calendarId, EnumCalendarInfoC
482
485
char * localeNamePtr = localeNameBuf;
483
486
char * parentNamePtr = parentNameBuf;
484
487
485
- strncpy (localeNamePtr, locale. getName () , ULOC_FULLNAME_CAPACITY);
488
+ strncpy (localeNamePtr, locale, ULOC_FULLNAME_CAPACITY);
486
489
487
490
while (true )
488
491
{
@@ -564,37 +567,38 @@ extern "C" int32_t EnumCalendarInfo(EnumCalendarInfoCallback callback,
564
567
// ShortDates to map kShort and kMedium in ICU, but also adding the "yMd"
565
568
// skeleton as well, as this
566
569
// closely matches what is used on Windows
567
- return InvokeCallbackForDateTimePattern (locale, UDAT_YEAR_NUM_MONTH_DAY_UCHAR, callback, context) &&
568
- InvokeCallbackForDatePattern (locale, UDAT_SHORT, callback, context) &&
569
- InvokeCallbackForDatePattern (locale, UDAT_MEDIUM, callback, context);
570
+ return InvokeCallbackForDateTimePattern (
571
+ locale.getName (), UDAT_YEAR_NUM_MONTH_DAY_UCHAR, callback, context) &&
572
+ InvokeCallbackForDatePattern (locale.getName (), UDAT_SHORT, callback, context) &&
573
+ InvokeCallbackForDatePattern (locale.getName (), UDAT_MEDIUM, callback, context);
570
574
case LongDates:
571
575
// LongDates map to kFull and kLong in ICU.
572
- return InvokeCallbackForDatePattern (locale, UDAT_FULL, callback, context) &&
573
- InvokeCallbackForDatePattern (locale, UDAT_LONG, callback, context);
576
+ return InvokeCallbackForDatePattern (locale. getName () , UDAT_FULL, callback, context) &&
577
+ InvokeCallbackForDatePattern (locale. getName () , UDAT_LONG, callback, context);
574
578
case YearMonths:
575
- return InvokeCallbackForDateTimePattern (locale, UDAT_YEAR_MONTH_UCHAR, callback, context);
579
+ return InvokeCallbackForDateTimePattern (locale. getName () , UDAT_YEAR_MONTH_UCHAR, callback, context);
576
580
case DayNames:
577
- return EnumSymbols (locale, calendarId, UDAT_STANDALONE_WEEKDAYS, 1 , callback, context);
581
+ return EnumSymbols (locale. getName () , calendarId, UDAT_STANDALONE_WEEKDAYS, 1 , callback, context);
578
582
case AbbrevDayNames:
579
- return EnumSymbols (locale, calendarId, UDAT_STANDALONE_SHORT_WEEKDAYS, 1 , callback, context);
583
+ return EnumSymbols (locale. getName () , calendarId, UDAT_STANDALONE_SHORT_WEEKDAYS, 1 , callback, context);
580
584
case MonthNames:
581
- return EnumSymbols (locale, calendarId, UDAT_STANDALONE_MONTHS, 0 , callback, context);
585
+ return EnumSymbols (locale. getName () , calendarId, UDAT_STANDALONE_MONTHS, 0 , callback, context);
582
586
case AbbrevMonthNames:
583
- return EnumSymbols (locale, calendarId, UDAT_STANDALONE_SHORT_MONTHS, 0 , callback, context);
587
+ return EnumSymbols (locale. getName () , calendarId, UDAT_STANDALONE_SHORT_MONTHS, 0 , callback, context);
584
588
case SuperShortDayNames:
585
589
#ifdef HAVE_DTWIDTHTYPE_SHORT
586
- return EnumSymbols (locale, calendarId, UDAT_STANDALONE_SHORTER_WEEKDAYS, 1 , callback, context);
590
+ return EnumSymbols (locale. getName () , calendarId, UDAT_STANDALONE_SHORTER_WEEKDAYS, 1 , callback, context);
587
591
#else
588
- return EnumSymbols (locale, calendarId, UDAT_STANDALONE_NARROW_WEEKDAYS, 1 , callback, context);
592
+ return EnumSymbols (locale. getName () , calendarId, UDAT_STANDALONE_NARROW_WEEKDAYS, 1 , callback, context);
589
593
#endif
590
594
case MonthGenitiveNames:
591
- return EnumSymbols (locale, calendarId, UDAT_MONTHS, 0 , callback, context);
595
+ return EnumSymbols (locale. getName () , calendarId, UDAT_MONTHS, 0 , callback, context);
592
596
case AbbrevMonthGenitiveNames:
593
- return EnumSymbols (locale, calendarId, UDAT_SHORT_MONTHS, 0 , callback, context);
597
+ return EnumSymbols (locale. getName () , calendarId, UDAT_SHORT_MONTHS, 0 , callback, context);
594
598
case EraNames:
595
- return EnumSymbols (locale, calendarId, UDAT_ERAS, 0 , callback, context);
599
+ return EnumSymbols (locale. getName () , calendarId, UDAT_ERAS, 0 , callback, context);
596
600
case AbbrevEraNames:
597
- return EnumAbbrevEraNames (locale, calendarId, callback, context);
601
+ return EnumAbbrevEraNames (locale. getName () , calendarId, callback, context);
598
602
default :
599
603
assert (false );
600
604
return false ;
0 commit comments