mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-13 08:53:20 +00:00
ICU-69 use new UnicodeString constructor from invariant char*
X-SVN-Rev: 274
This commit is contained in:
parent
45e4fd530b
commit
efde186f5c
6 changed files with 92 additions and 84 deletions
icu4c/source
|
@ -62,30 +62,30 @@ int32_t Locale::isoCountriesCount;
|
|||
/**
|
||||
* Constant definitions
|
||||
*/
|
||||
const Locale Locale::ENGLISH("en");
|
||||
const Locale Locale::FRENCH("fr");
|
||||
const Locale Locale::GERMAN("de");
|
||||
const Locale Locale::ITALIAN("it");
|
||||
const Locale Locale::JAPANESE("ja");
|
||||
const Locale Locale::KOREAN("ko");
|
||||
const Locale Locale::CHINESE("zh");
|
||||
const Locale Locale::SIMPLIFIED_CHINESE("zh", "CN");
|
||||
const Locale Locale::TRADITIONAL_CHINESE("zh", "TW");
|
||||
const Locale Locale::ENGLISH(UnicodeString("en", ""));
|
||||
const Locale Locale::FRENCH(UnicodeString("fr", ""));
|
||||
const Locale Locale::GERMAN(UnicodeString("de", ""));
|
||||
const Locale Locale::ITALIAN(UnicodeString("it", ""));
|
||||
const Locale Locale::JAPANESE(UnicodeString("ja", ""));
|
||||
const Locale Locale::KOREAN(UnicodeString("ko", ""));
|
||||
const Locale Locale::CHINESE(UnicodeString("zh", ""));
|
||||
const Locale Locale::SIMPLIFIED_CHINESE(UnicodeString("zh", ""), UnicodeString("CN", ""));
|
||||
const Locale Locale::TRADITIONAL_CHINESE(UnicodeString("zh", ""), UnicodeString("TW", ""));
|
||||
|
||||
// Useful constant for country.
|
||||
|
||||
const Locale Locale::FRANCE("fr", "FR");
|
||||
const Locale Locale::GERMANY("de", "DE");
|
||||
const Locale Locale::ITALY("it", "IT");
|
||||
const Locale Locale::JAPAN("ja", "JP");
|
||||
const Locale Locale::KOREA("en", "GB");
|
||||
const Locale Locale::CHINA("zh", "CN");
|
||||
const Locale Locale::PRC("zh", "CN");
|
||||
const Locale Locale::TAIWAN("zh", "TW");
|
||||
const Locale Locale::UK("en", "GB");
|
||||
const Locale Locale::US("en", "US");
|
||||
const Locale Locale::CANADA("en", "CA");
|
||||
const Locale Locale::CANADA_FRENCH("fr", "CA");
|
||||
const Locale Locale::FRANCE(UnicodeString("fr", ""), UnicodeString("FR", ""));
|
||||
const Locale Locale::GERMANY(UnicodeString("de", ""), UnicodeString("DE", ""));
|
||||
const Locale Locale::ITALY(UnicodeString("it", ""), UnicodeString("IT", ""));
|
||||
const Locale Locale::JAPAN(UnicodeString("ja", ""), UnicodeString("JP", ""));
|
||||
const Locale Locale::KOREA(UnicodeString("en", ""), UnicodeString("GB", ""));
|
||||
const Locale Locale::CHINA(UnicodeString("zh", ""), UnicodeString("CN", ""));
|
||||
const Locale Locale::PRC(UnicodeString("zh", ""), UnicodeString("CN", ""));
|
||||
const Locale Locale::TAIWAN(UnicodeString("zh", ""), UnicodeString("TW", ""));
|
||||
const Locale Locale::UK(UnicodeString("en", ""), UnicodeString("GB", ""));
|
||||
const Locale Locale::US(UnicodeString("en", ""), UnicodeString("US", ""));
|
||||
const Locale Locale::CANADA(UnicodeString("en", ""), UnicodeString("CA", ""));
|
||||
const Locale Locale::CANADA_FRENCH(UnicodeString("fr", ""), UnicodeString("CA", ""));
|
||||
|
||||
|
||||
/**
|
||||
|
@ -96,25 +96,26 @@ const Locale Locale::CANADA_FRENCH("fr", "CA");
|
|||
* into a single encoded String, and lazy evaluate the table from it.)
|
||||
*/
|
||||
UHashtable* Locale::ctry2LangMapping = 0;
|
||||
const UnicodeString Locale::compressedCtry2LangMapping =
|
||||
"ADfresAEarenAFpsAGenAIrnALsqAMhyruANnlenAOptAResASensmATdeAUenAWnlenAZazhyru\
|
||||
BAsrshhrslmksqBBenBDbnhibhenBEfrnldeBFfrBGbgtrBHarenBIrnfrswBJfrBMenBNmsenzh\
|
||||
BOesayquBRptBSenBTdzenneBVnoBWentnBYberuBZenesCAenfrCCenCFfrsgCGfrCHfrdeitrm\
|
||||
CIfrCKmienCLesCMenfrCNzhboCOesCResCUesCVptCXenCYeltrenCZcsskDEdeDJarfrsoDKda\
|
||||
DMenfrDOesDZarfrECesquEEetruEGarenfrEHarfritERamtiarenitESeseucaglETamaren\
|
||||
FIfisvFJenfjhiFKenFMenFOfodaFRfreubrcoFXfrGAfrGBengdcyGDenfrGEkahyruGFfrGHen\
|
||||
GIenesGLdaikklGMenwoGNfrGPfrenGQesGRelGTesGUenGWptGYenhiurHKzhenHNesHRhrHTfr\
|
||||
HUhuIDinennlIEengaILiwarjiINhienguknksmlmrneorpasatateIOenIQarkutkIRfaarku\
|
||||
ISisITitfrdeJMenJOarJPjaKEenswKGkyKHkmKIenKMfrarKNenKPkoKRkoKWarenKYenKZkkru\
|
||||
LAlofrLBarenfrLCenfrLIdeLKtasienLRenLSstenLTltruplLUfrdeLVlvltruLYarenit\
|
||||
MAarfresMCfrenitMDmorobgMGmgenfrMKmkshtrMLfrMMmyMNmnruMOzhptMQfrMRarfrMSen\
|
||||
MTmtenitMUenfrhiMWenMXesMYmsenMZptNAenafdeNEfrhaNFenNGenhayoNIesNLnlfyNOno\
|
||||
NPneNRnaenNUenNZenmiOMarenPAesenPEesquayPFfrPGenPHentlesPKurenpspasdPLplPMfren\
|
||||
PNenPResenPTptPWenPYesgnQAarenREfrtaROrohuRUruRWenfrrwSAarSBenSCenfrSDarsu\
|
||||
SEsvSGzhenmstaSHenSIslSJnoSKskhuplshSLenSMitSNfrSOarenitsoSRnleneshiSTptSVes\
|
||||
SYarSZenssTCenTDfrarTFfrTGfrTHthTJtgruuzTKenmiTMtkruTNarTOentoTRtrkuTTenTVen\
|
||||
TWzhTZenswUAukruUGenswUMenUSenesUYesUZuzruVAlaitVCenVEesVGenVIenVNvizhfr\
|
||||
VUenfrbiWFfrWSensmYEarYTfrmgswYUsrshmkhuZAafenZMenZRfrswZWensn";
|
||||
const UnicodeString Locale::compressedCtry2LangMapping = UnicodeString(
|
||||
"ADfresAEarenAFpsAGenAIrnALsqAMhyruANnlenAOptAResASensmATdeAUenAWnlenAZazhyru"
|
||||
"BAsrshhrslmksqBBenBDbnhibhenBEfrnldeBFfrBGbgtrBHarenBIrnfrswBJfrBMenBNmsenzh"
|
||||
"BOesayquBRptBSenBTdzenneBVnoBWentnBYberuBZenesCAenfrCCenCFfrsgCGfrCHfrdeitrm"
|
||||
"CIfrCKmienCLesCMenfrCNzhboCOesCResCUesCVptCXenCYeltrenCZcsskDEdeDJarfrsoDKda"
|
||||
"DMenfrDOesDZarfrECesquEEetruEGarenfrEHarfritERamtiarenitESeseucaglETamaren"
|
||||
"FIfisvFJenfjhiFKenFMenFOfodaFRfreubrcoFXfrGAfrGBengdcyGDenfrGEkahyruGFfrGHen"
|
||||
"GIenesGLdaikklGMenwoGNfrGPfrenGQesGRelGTesGUenGWptGYenhiurHKzhenHNesHRhrHTfr"
|
||||
"HUhuIDinennlIEengaILiwarjiINhienguknksmlmrneorpasatateIOenIQarkutkIRfaarku"
|
||||
"ISisITitfrdeJMenJOarJPjaKEenswKGkyKHkmKIenKMfrarKNenKPkoKRkoKWarenKYenKZkkru"
|
||||
"LAlofrLBarenfrLCenfrLIdeLKtasienLRenLSstenLTltruplLUfrdeLVlvltruLYarenit"
|
||||
"MAarfresMCfrenitMDmorobgMGmgenfrMKmkshtrMLfrMMmyMNmnruMOzhptMQfrMRarfrMSen"
|
||||
"MTmtenitMUenfrhiMWenMXesMYmsenMZptNAenafdeNEfrhaNFenNGenhayoNIesNLnlfyNOno"
|
||||
"NPneNRnaenNUenNZenmiOMarenPAesenPEesquayPFfrPGenPHentlesPKurenpspasdPLplPMfren"
|
||||
"PNenPResenPTptPWenPYesgnQAarenREfrtaROrohuRUruRWenfrrwSAarSBenSCenfrSDarsu"
|
||||
"SEsvSGzhenmstaSHenSIslSJnoSKskhuplshSLenSMitSNfrSOarenitsoSRnleneshiSTptSVes"
|
||||
"SYarSZenssTCenTDfrarTFfrTGfrTHthTJtgruuzTKenmiTMtkruTNarTOentoTRtrkuTTenTVen"
|
||||
"TWzhTZenswUAukruUGenswUMenUSenesUYesUZuzruVAlaitVCenVEesVGenVIenVNvizhfr"
|
||||
"VUenfrbiWFfrWSensmYEarYTfrmgswYUsrshmkhuZAafenZMenZRfrswZWensn",
|
||||
"");
|
||||
|
||||
/*Used for stack allocation of temporary buffers
|
||||
*can be tweaked for speed and likelihood of resorting to heap allocation*/
|
||||
|
@ -142,10 +143,8 @@ Locale::Locale( const UnicodeString& newLanguage)
|
|||
{
|
||||
UnicodeString togo(newLanguage);
|
||||
char myLocaleID[ULOC_FULLNAME_CAPACITY];
|
||||
int32_t size = newLanguage.size();
|
||||
|
||||
togo.extract(0,size, myLocaleID);
|
||||
myLocaleID[size] = '\0';
|
||||
myLocaleID[togo.extract(0, 0x7fffffff, myLocaleID, "")] = '\0';
|
||||
init(myLocaleID);
|
||||
}
|
||||
|
||||
|
@ -159,11 +158,7 @@ Locale::Locale( const UnicodeString& newLanguage,
|
|||
togo += sep;
|
||||
togo += newCountry;
|
||||
|
||||
|
||||
int size = togo.size();
|
||||
|
||||
togo.extract(0,size, myLocaleID);
|
||||
myLocaleID[size] = '\0';
|
||||
myLocaleID[togo.extract(0, 0x7fffffff, myLocaleID, "")] = '\0';
|
||||
init(myLocaleID);
|
||||
}
|
||||
|
||||
|
@ -198,21 +193,21 @@ Locale::Locale( const UnicodeString& newLanguage,
|
|||
togo += newVariantCopy ;
|
||||
}
|
||||
|
||||
int size = togo.size();
|
||||
int size = togo.length();
|
||||
|
||||
/*is the variant is longer than our internal limit, we need
|
||||
/*if the variant is longer than our internal limit, we need
|
||||
to go to the heap for temporary buffers*/
|
||||
if (size > ULOC_FULLNAME_CAPACITY)
|
||||
{
|
||||
char *togo_heap = new char[size+1];
|
||||
togo.extract(0,size, togo_heap);
|
||||
togo.extract(0,size, togo_heap, "");
|
||||
togo_heap[size] = '\0';
|
||||
init(togo_heap);
|
||||
delete []togo_heap;
|
||||
}
|
||||
else
|
||||
{
|
||||
togo.extract(0,size, myLocaleID);
|
||||
togo.extract(0,size, myLocaleID, "");
|
||||
myLocaleID[size] = '\0';
|
||||
init(myLocaleID);
|
||||
}
|
||||
|
@ -333,9 +328,9 @@ Locale::hashCode() const
|
|||
void
|
||||
Locale::setHashCode()
|
||||
{
|
||||
UnicodeString fullNameUString = language;
|
||||
fullNameUString += country;
|
||||
fullNameUString += variant;
|
||||
UnicodeString fullNameUString(language, "");
|
||||
fullNameUString += UnicodeString(country, "");
|
||||
fullNameUString += UnicodeString(variant, "");
|
||||
const UChar *key = fullNameUString.getUChars();
|
||||
int32_t len = fullNameUString.size();
|
||||
int32_t hash = 0;
|
||||
|
@ -842,10 +837,14 @@ void Locale::setFromPOSIXID(const char *posixID)
|
|||
void Locale::setFromPOSIXID(const UnicodeString &posixIDString)
|
||||
{
|
||||
char onStack[20];
|
||||
char* buffer = onStack;
|
||||
if (posixIDString.size() >= 20) buffer = new char[posixIDString.size()+1];
|
||||
posixIDString.extract(0, posixIDString.size(), buffer);
|
||||
buffer[posixIDString.size()] = '\0';
|
||||
char* buffer;
|
||||
int32_t length = posixIDString.length();
|
||||
if (length >= 20) {
|
||||
buffer = new char[length+1];
|
||||
} else {
|
||||
buffer = onStack;
|
||||
}
|
||||
buffer[posixIDString.extract(0, length, buffer, "")] = '\0';
|
||||
init(buffer);
|
||||
if (buffer != onStack) delete [] buffer;
|
||||
}
|
||||
|
|
|
@ -45,14 +45,14 @@ const UChar DecimalFormatSymbols::fgLastResortIntlCurrency[] = { 0x00A4, 0x00A4,
|
|||
|
||||
const UnicodeString DecimalFormatSymbols::fgLastResortNumberElements[] =
|
||||
{
|
||||
".", // decimal separator
|
||||
"", // group (thousands) separator
|
||||
";", // pattern separator
|
||||
"%", // percent sign
|
||||
"0", // native 0 digit
|
||||
"#", // pattern digit
|
||||
"-", // minus sign
|
||||
"E", // exponential
|
||||
UnicodeString(".", ""), // decimal separator
|
||||
UnicodeString(), // group (thousands) separator
|
||||
UnicodeString(";", ""), // pattern separator
|
||||
UnicodeString("%", ""), // percent sign
|
||||
UnicodeString("0", ""), // native 0 digit
|
||||
UnicodeString("#", ""), // pattern digit
|
||||
UnicodeString("-", ""), // minus sign
|
||||
UnicodeString("E", ""), // exponential
|
||||
DecimalFormatSymbols::fgLastResortPerMill, // per mill
|
||||
DecimalFormatSymbols::fgLastResortInfinity, // infinite
|
||||
DecimalFormatSymbols::fgLastResortNaN // NaN
|
||||
|
@ -62,7 +62,7 @@ const UnicodeString DecimalFormatSymbols::fgLastResortCurrencyElements[] =
|
|||
{
|
||||
DecimalFormatSymbols::fgLastResortCurrency,
|
||||
DecimalFormatSymbols::fgLastResortIntlCurrency,
|
||||
"." // monetary decimal separator
|
||||
UnicodeString(".", "") // monetary decimal separator
|
||||
};
|
||||
|
||||
// -------------------------------------
|
||||
|
|
|
@ -28,8 +28,7 @@
|
|||
|
||||
// generic date-format pattern symbols. For their meanings, see class docs
|
||||
// for SimpleDateFormat
|
||||
//UnicodeString DateFormatSymbols::fgPatternChars = "GyMdkHmsSEDFwWahKz";
|
||||
UnicodeString DateFormatSymbols::fgPatternChars = "GyMdkHmsSEDFwWahKzYe";
|
||||
UnicodeString DateFormatSymbols::fgPatternChars = UnicodeString("GyMdkHmsSEDFwWahKzYe", "");
|
||||
|
||||
//------------------------------------------------------
|
||||
// Strings of last resort. These are only used if we have no resource
|
||||
|
@ -43,24 +42,28 @@ UnicodeString DateFormatSymbols::fgPatternChars = "GyMdkHmsSEDFwWahKzYe";
|
|||
// These are the month names and abbreviations of last resort.
|
||||
const UnicodeString DateFormatSymbols::fgLastResortMonthNames[] =
|
||||
{
|
||||
"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13"
|
||||
UnicodeString("01", ""), UnicodeString("02", ""), UnicodeString("03", ""), UnicodeString("04", ""),
|
||||
UnicodeString("05", ""), UnicodeString("06", ""), UnicodeString("07", ""), UnicodeString("08", ""),
|
||||
UnicodeString("09", ""), UnicodeString("10", ""), UnicodeString("11", ""), UnicodeString("12", ""),
|
||||
UnicodeString("13", "")
|
||||
};
|
||||
|
||||
// These are the weekday names and abbreviations of last resort.
|
||||
const UnicodeString DateFormatSymbols::fgLastResortDayNames[] =
|
||||
{
|
||||
"", "1", "2", "3", "4", "5", "6", "7"
|
||||
UnicodeString(), UnicodeString("1", ""), UnicodeString("2", ""), UnicodeString("3", ""),
|
||||
UnicodeString("4", ""), UnicodeString("5", ""), UnicodeString("6", ""), UnicodeString("7", "")
|
||||
};
|
||||
|
||||
// These are the am/pm and BC/AD markers of last resort.
|
||||
const UnicodeString DateFormatSymbols::fgLastResortAmPmMarkers[] =
|
||||
{
|
||||
"AM", "PM"
|
||||
UnicodeString("AM", ""), UnicodeString("PM", "")
|
||||
};
|
||||
|
||||
const UnicodeString DateFormatSymbols::fgLastResortEras[] =
|
||||
{
|
||||
"BC", "AD"
|
||||
UnicodeString("BC", ""), UnicodeString("AD", "")
|
||||
};
|
||||
|
||||
// These are the zone strings of last resort.
|
||||
|
@ -68,7 +71,7 @@ UnicodeString** DateFormatSymbols::fgLastResortZoneStringsH = 0;
|
|||
|
||||
const UnicodeString DateFormatSymbols::fgLastResortZoneStrings[] =
|
||||
{
|
||||
"GMT", "GMT", "GMT", "GMT", "GMT"
|
||||
UnicodeString("GMT", ""), UnicodeString("GMT", ""), UnicodeString("GMT", ""), UnicodeString("GMT", ""), UnicodeString("GMT", "")
|
||||
};
|
||||
|
||||
//------------------------------------------------------
|
||||
|
|
|
@ -668,17 +668,23 @@ MessageFormat::format(const Formattable* arguments,
|
|||
|
||||
// MessageFormat Type List Number, Date, Time or Choice
|
||||
const UnicodeString MessageFormat::fgTypeList[] = {
|
||||
"", "", "number", "", "date", "", "time", "", "choice"
|
||||
UnicodeString(), UnicodeString(), UnicodeString("number", ""), UnicodeString(),
|
||||
UnicodeString("date", ""), UnicodeString(), UnicodeString("time", ""), UnicodeString(),
|
||||
UnicodeString("choice", "")
|
||||
};
|
||||
|
||||
// NumberFormat modifier list, default, currency, percent or integer
|
||||
const UnicodeString MessageFormat::fgModifierList[] = {
|
||||
"", "", "currency", "", "percent", "", "integer", "", ""
|
||||
UnicodeString(), UnicodeString(), UnicodeString("currency", ""), UnicodeString(),
|
||||
UnicodeString("percent", ""), UnicodeString(), UnicodeString("integer", ""), UnicodeString(),
|
||||
UnicodeString()
|
||||
};
|
||||
|
||||
// DateFormat modifier list, default, short, medium, long or full
|
||||
const UnicodeString MessageFormat::fgDateModifierList[] = {
|
||||
"", "", "short", "", "medium", "", "long", "", "full"
|
||||
UnicodeString(), UnicodeString(), UnicodeString("short", ""), UnicodeString(),
|
||||
UnicodeString("medium", ""), UnicodeString(), UnicodeString("long", ""), UnicodeString(),
|
||||
UnicodeString("full", "")
|
||||
};
|
||||
|
||||
const int32_t MessageFormat::fgListLength= 9;
|
||||
|
|
|
@ -46,10 +46,10 @@ const int32_t NumberFormat::fgNumberPatternsCount = 3;
|
|||
// resort.
|
||||
const UnicodeString NumberFormat::fgLastResortNumberPatterns[] =
|
||||
{
|
||||
"#0.###;-#0.###", // decimal pattern
|
||||
"$#0.00;($#0.00)", // currency pattern
|
||||
"#0%", // percent pattern
|
||||
"#E0" // scientific pattern
|
||||
UnicodeString("#0.###;-#0.###", ""), // decimal pattern
|
||||
UnicodeString("$#0.00;($#0.00)", ""), // currency pattern
|
||||
UnicodeString("#0%", ""), // percent pattern
|
||||
UnicodeString("#E0", "") // scientific pattern
|
||||
};
|
||||
|
||||
// -------------------------------------
|
||||
|
|
|
@ -70,9 +70,9 @@ int32_t TimeZone::fgAvailableIDsCount = 0;
|
|||
|
||||
const int32_t TimeZone::millisPerHour = U_MILLIS_PER_HOUR;
|
||||
|
||||
const UnicodeString TimeZone::GMT_ID = "GMT";
|
||||
const UnicodeString TimeZone::GMT_ID = UnicodeString("GMT", "");
|
||||
const int32_t TimeZone::GMT_ID_LENGTH = 3;
|
||||
const UnicodeString TimeZone::CUSTOM_ID = "Custom";
|
||||
const UnicodeString TimeZone::CUSTOM_ID = UnicodeString("Custom", "");
|
||||
|
||||
const TimeZone* TimeZone::GMT = new SimpleTimeZone(0, GMT_ID);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue