@@ -209,12 +209,14 @@ Returns the list of CalendarIds that are available for the specified locale.
209
209
*/
210
210
extern " C" int32_t GetCalendars (const UChar* localeName, CalendarId* calendars, int32_t calendarsCapacity)
211
211
{
212
- Locale locale = GetLocale (localeName);
213
- if (locale.isBogus ())
212
+ UErrorCode err = U_ZERO_ERROR;
213
+ char locale[ULOC_FULLNAME_CAPACITY];
214
+ GetLocale (localeName, locale, ULOC_FULLNAME_CAPACITY, false , &err);
215
+
216
+ if (U_FAILURE (err))
214
217
return 0 ;
215
218
216
- UErrorCode err = U_ZERO_ERROR;
217
- UEnumeration* pEnum = ucal_getKeywordValuesForLocale (" calendar" , locale.getName (), TRUE , &err);
219
+ UEnumeration* pEnum = ucal_getKeywordValuesForLocale (" calendar" , locale, TRUE , &err);
218
220
UEnumerationHolder enumHolder (pEnum, err);
219
221
220
222
if (U_FAILURE (err))
@@ -291,16 +293,19 @@ with the requested value.
291
293
extern " C" CalendarDataResult GetCalendarInfo (
292
294
const UChar* localeName, CalendarId calendarId, CalendarDataType dataType, UChar* result, int32_t resultCapacity)
293
295
{
294
- Locale locale = GetLocale (localeName);
295
- if (locale.isBogus ())
296
+ UErrorCode err = U_ZERO_ERROR;
297
+ char locale[ULOC_FULLNAME_CAPACITY];
298
+ GetLocale (localeName, locale, ULOC_FULLNAME_CAPACITY, false , &err);
299
+
300
+ if (U_FAILURE (err))
296
301
return UnknownError;
297
302
298
303
switch (dataType)
299
304
{
300
305
case NativeName:
301
- return GetNativeCalendarName (locale. getName () , calendarId, result, resultCapacity);
306
+ return GetNativeCalendarName (locale, calendarId, result, resultCapacity);
302
307
case MonthDay:
303
- return GetMonthDayPattern (locale. getName () , result, resultCapacity);
308
+ return GetMonthDayPattern (locale, result, resultCapacity);
304
309
default :
305
310
assert (false );
306
311
return UnknownError;
@@ -557,8 +562,11 @@ extern "C" int32_t EnumCalendarInfo(EnumCalendarInfoCallback callback,
557
562
CalendarDataType dataType,
558
563
const void * context)
559
564
{
560
- Locale locale = GetLocale (localeName);
561
- if (locale.isBogus ())
565
+ UErrorCode err = U_ZERO_ERROR;
566
+ char locale[ULOC_FULLNAME_CAPACITY];
567
+ GetLocale (localeName, locale, ULOC_FULLNAME_CAPACITY, false , &err);
568
+
569
+ if (U_FAILURE (err))
562
570
return false ;
563
571
564
572
switch (dataType)
@@ -567,38 +575,37 @@ extern "C" int32_t EnumCalendarInfo(EnumCalendarInfoCallback callback,
567
575
// ShortDates to map kShort and kMedium in ICU, but also adding the "yMd"
568
576
// skeleton as well, as this
569
577
// closely matches what is used on Windows
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);
578
+ return InvokeCallbackForDateTimePattern (locale, UDAT_YEAR_NUM_MONTH_DAY_UCHAR, callback, context) &&
579
+ InvokeCallbackForDatePattern (locale, UDAT_SHORT, callback, context) &&
580
+ InvokeCallbackForDatePattern (locale, UDAT_MEDIUM, callback, context);
574
581
case LongDates:
575
582
// LongDates map to kFull and kLong in ICU.
576
- return InvokeCallbackForDatePattern (locale. getName () , UDAT_FULL, callback, context) &&
577
- InvokeCallbackForDatePattern (locale. getName () , UDAT_LONG, callback, context);
583
+ return InvokeCallbackForDatePattern (locale, UDAT_FULL, callback, context) &&
584
+ InvokeCallbackForDatePattern (locale, UDAT_LONG, callback, context);
578
585
case YearMonths:
579
- return InvokeCallbackForDateTimePattern (locale. getName () , UDAT_YEAR_MONTH_UCHAR, callback, context);
586
+ return InvokeCallbackForDateTimePattern (locale, UDAT_YEAR_MONTH_UCHAR, callback, context);
580
587
case DayNames:
581
- return EnumSymbols (locale. getName () , calendarId, UDAT_STANDALONE_WEEKDAYS, 1 , callback, context);
588
+ return EnumSymbols (locale, calendarId, UDAT_STANDALONE_WEEKDAYS, 1 , callback, context);
582
589
case AbbrevDayNames:
583
- return EnumSymbols (locale. getName () , calendarId, UDAT_STANDALONE_SHORT_WEEKDAYS, 1 , callback, context);
590
+ return EnumSymbols (locale, calendarId, UDAT_STANDALONE_SHORT_WEEKDAYS, 1 , callback, context);
584
591
case MonthNames:
585
- return EnumSymbols (locale. getName () , calendarId, UDAT_STANDALONE_MONTHS, 0 , callback, context);
592
+ return EnumSymbols (locale, calendarId, UDAT_STANDALONE_MONTHS, 0 , callback, context);
586
593
case AbbrevMonthNames:
587
- return EnumSymbols (locale. getName () , calendarId, UDAT_STANDALONE_SHORT_MONTHS, 0 , callback, context);
594
+ return EnumSymbols (locale, calendarId, UDAT_STANDALONE_SHORT_MONTHS, 0 , callback, context);
588
595
case SuperShortDayNames:
589
596
#ifdef HAVE_DTWIDTHTYPE_SHORT
590
- return EnumSymbols (locale. getName () , calendarId, UDAT_STANDALONE_SHORTER_WEEKDAYS, 1 , callback, context);
597
+ return EnumSymbols (locale, calendarId, UDAT_STANDALONE_SHORTER_WEEKDAYS, 1 , callback, context);
591
598
#else
592
- return EnumSymbols (locale. getName () , calendarId, UDAT_STANDALONE_NARROW_WEEKDAYS, 1 , callback, context);
599
+ return EnumSymbols (locale, calendarId, UDAT_STANDALONE_NARROW_WEEKDAYS, 1 , callback, context);
593
600
#endif
594
601
case MonthGenitiveNames:
595
- return EnumSymbols (locale. getName () , calendarId, UDAT_MONTHS, 0 , callback, context);
602
+ return EnumSymbols (locale, calendarId, UDAT_MONTHS, 0 , callback, context);
596
603
case AbbrevMonthGenitiveNames:
597
- return EnumSymbols (locale. getName () , calendarId, UDAT_SHORT_MONTHS, 0 , callback, context);
604
+ return EnumSymbols (locale, calendarId, UDAT_SHORT_MONTHS, 0 , callback, context);
598
605
case EraNames:
599
- return EnumSymbols (locale. getName () , calendarId, UDAT_ERAS, 0 , callback, context);
606
+ return EnumSymbols (locale, calendarId, UDAT_ERAS, 0 , callback, context);
600
607
case AbbrevEraNames:
601
- return EnumAbbrevEraNames (locale. getName () , calendarId, callback, context);
608
+ return EnumAbbrevEraNames (locale, calendarId, callback, context);
602
609
default :
603
610
assert (false );
604
611
return false ;
0 commit comments