mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-14 01:11:02 +00:00
ICU-20445 Pass ByteSink to ulocimp_addLikelySubtags().
This commit is contained in:
parent
974087aa0b
commit
4bd1ee008c
3 changed files with 27 additions and 9 deletions
|
@ -19,12 +19,15 @@
|
|||
#include "unicode/udat.h"
|
||||
#include "unicode/ustring.h"
|
||||
#include "unicode/utf16.h"
|
||||
#include "bytesinkutil.h"
|
||||
#include "charstr.h"
|
||||
#include "tzgnames.h"
|
||||
#include "cmemory.h"
|
||||
#include "cstring.h"
|
||||
#include "putilimp.h"
|
||||
#include "uassert.h"
|
||||
#include "ucln_in.h"
|
||||
#include "ulocimp.h"
|
||||
#include "umutex.h"
|
||||
#include "uresimp.h"
|
||||
#include "ureslocs.h"
|
||||
|
@ -327,10 +330,13 @@ TimeZoneFormat::TimeZoneFormat(const Locale& locale, UErrorCode& status)
|
|||
const char* region = fLocale.getCountry();
|
||||
int32_t regionLen = static_cast<int32_t>(uprv_strlen(region));
|
||||
if (regionLen == 0) {
|
||||
char loc[ULOC_FULLNAME_CAPACITY];
|
||||
uloc_addLikelySubtags(fLocale.getName(), loc, sizeof(loc), &status);
|
||||
CharString loc;
|
||||
{
|
||||
CharStringByteSink sink(&loc);
|
||||
ulocimp_addLikelySubtags(fLocale.getName(), sink, &status);
|
||||
}
|
||||
|
||||
regionLen = uloc_getCountry(loc, fTargetRegion, sizeof(fTargetRegion), &status);
|
||||
regionLen = uloc_getCountry(loc.data(), fTargetRegion, sizeof(fTargetRegion), &status);
|
||||
if (U_SUCCESS(status)) {
|
||||
fTargetRegion[regionLen] = 0;
|
||||
} else {
|
||||
|
|
|
@ -21,12 +21,15 @@
|
|||
#include "unicode/strenum.h"
|
||||
#include "unicode/vtzone.h"
|
||||
|
||||
#include "bytesinkutil.h"
|
||||
#include "charstr.h"
|
||||
#include "cmemory.h"
|
||||
#include "cstring.h"
|
||||
#include "mutex.h"
|
||||
#include "uhash.h"
|
||||
#include "uassert.h"
|
||||
#include "umutex.h"
|
||||
#include "ulocimp.h"
|
||||
#include "uresimp.h"
|
||||
#include "ureslocs.h"
|
||||
#include "zonemeta.h"
|
||||
|
@ -412,10 +415,13 @@ TZGNCore::initialize(const Locale& locale, UErrorCode& status) {
|
|||
const char* region = fLocale.getCountry();
|
||||
int32_t regionLen = static_cast<int32_t>(uprv_strlen(region));
|
||||
if (regionLen == 0) {
|
||||
char loc[ULOC_FULLNAME_CAPACITY];
|
||||
uloc_addLikelySubtags(fLocale.getName(), loc, sizeof(loc), &status);
|
||||
CharString loc;
|
||||
{
|
||||
CharStringByteSink sink(&loc);
|
||||
ulocimp_addLikelySubtags(fLocale.getName(), sink, &status);
|
||||
}
|
||||
|
||||
regionLen = uloc_getCountry(loc, fTargetRegion, sizeof(fTargetRegion), &status);
|
||||
regionLen = uloc_getCountry(loc.data(), fTargetRegion, sizeof(fTargetRegion), &status);
|
||||
if (U_SUCCESS(status)) {
|
||||
fTargetRegion[regionLen] = 0;
|
||||
} else {
|
||||
|
|
|
@ -21,11 +21,14 @@
|
|||
#include "unicode/utf16.h"
|
||||
|
||||
#include "tznames_impl.h"
|
||||
#include "bytesinkutil.h"
|
||||
#include "charstr.h"
|
||||
#include "cmemory.h"
|
||||
#include "cstring.h"
|
||||
#include "uassert.h"
|
||||
#include "mutex.h"
|
||||
#include "resource.h"
|
||||
#include "ulocimp.h"
|
||||
#include "uresimp.h"
|
||||
#include "ureslocs.h"
|
||||
#include "zonemeta.h"
|
||||
|
@ -2135,9 +2138,12 @@ TZDBTimeZoneNames::TZDBTimeZoneNames(const Locale& locale)
|
|||
int32_t regionLen = static_cast<int32_t>(uprv_strlen(region));
|
||||
if (regionLen == 0) {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
char loc[ULOC_FULLNAME_CAPACITY];
|
||||
uloc_addLikelySubtags(fLocale.getName(), loc, sizeof(loc), &status);
|
||||
regionLen = uloc_getCountry(loc, fRegion, sizeof(fRegion), &status);
|
||||
CharString loc;
|
||||
{
|
||||
CharStringByteSink sink(&loc);
|
||||
ulocimp_addLikelySubtags(fLocale.getName(), sink, &status);
|
||||
}
|
||||
regionLen = uloc_getCountry(loc.data(), fRegion, sizeof(fRegion), &status);
|
||||
if (U_SUCCESS(status) && regionLen < (int32_t)sizeof(fRegion)) {
|
||||
useWorld = FALSE;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue