本文整理汇总了C++中Locale函数的典型用法代码示例。如果您正苦于以下问题:C++ Locale函数的具体用法?C++ Locale怎么用?C++ Locale使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Locale函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Locale
Locale
RuleBasedNumberFormat::getRuleSetDisplayNameLocale(int32_t index, UErrorCode& status) const {
if (U_FAILURE(status)) {
return Locale("");
}
if (localizations && index >= 0 && index < localizations->getNumberOfDisplayLocales()) {
UnicodeString name(TRUE, localizations->getLocaleName(index), -1);
char buffer[64];
int32_t cap = name.length() + 1;
char* bp = buffer;
if (cap > 64) {
bp = (char *)uprv_malloc(cap);
if (bp == NULL) {
status = U_MEMORY_ALLOCATION_ERROR;
return Locale("");
}
}
name.extract(0, name.length(), bp, cap, UnicodeString::kInvariant);
Locale retLocale(bp);
if (bp != buffer) {
uprv_free(bp);
}
return retLocale;
}
status = U_ILLEGAL_ARGUMENT_ERROR;
Locale retLocale;
return retLocale;
}
开发者ID:thlorenz,项目名称:chromium-deps-icu52,代码行数:28,代码来源:rbnf.cpp
示例2: logln
void IntlTestNumberFormat::monsterTest(/* char* par */)
{
const char *SEP = "============================================================\n";
int32_t count;
const Locale* allLocales = NumberFormat::getAvailableLocales(count);
Locale* locales = (Locale*)allLocales;
Locale quickLocales[6];
if (allLocales && count)
{
if (quick && count > 6) {
logln("quick test: testing just 6 locales!");
count = 6;
locales = quickLocales;
locales[0] = allLocales[0];
locales[1] = allLocales[1];
locales[2] = allLocales[2];
// In a quick test, make sure we test locales that use
// currency prefix, currency suffix, and choice currency
// logic. Otherwise bugs in these areas can slip through.
locales[3] = Locale("ar", "AE", "");
locales[4] = Locale("cs", "CZ", "");
locales[5] = Locale("en", "IN", "");
}
for (int32_t i=0; i<count; ++i)
{
UnicodeString name(locales[i].getName(), "");
logln(SEP);
testLocale(/* par, */locales[i], name);
}
}
logln(SEP);
}
开发者ID:ACSOP,项目名称:android_external_icu4c,代码行数:33,代码来源:tsnmfmt.cpp
示例3: errcheckln
void RBBIAPITest::TestBoilerPlate()
{
UErrorCode status = U_ZERO_ERROR;
BreakIterator* a = BreakIterator::createWordInstance(Locale("hi"), status);
BreakIterator* b = BreakIterator::createWordInstance(Locale("hi_IN"),status);
if (U_FAILURE(status)) {
errcheckln(status, "Creation of break iterator failed %s", u_errorName(status));
return;
}
if(*a!=*b){
errln("Failed: boilerplate method operator!= does not return correct results");
}
// Japanese word break iterators are identical to root with
// a dictionary-based break iterator
BreakIterator* c = BreakIterator::createCharacterInstance(Locale("ja"),status);
BreakIterator* d = BreakIterator::createCharacterInstance(Locale("root"),status);
if(c && d){
if(*c!=*d){
errln("Failed: boilerplate method operator== does not return correct results");
}
}else{
errln("creation of break iterator failed");
}
delete a;
delete b;
delete c;
delete d;
}
开发者ID:Distrotech,项目名称:icu,代码行数:28,代码来源:rbbiapts.cpp
示例4: loadTestData
void
NewResourceBundleTest::TestResourceBundles()
{
UErrorCode status = U_ZERO_ERROR;
loadTestData(status);
if(U_FAILURE(status))
{
dataerrln("Could not load testdata.dat %s " + UnicodeString(u_errorName(status)));
return;
}
/* Make sure that users using te_IN for the default locale don't get test failures. */
Locale originalDefault;
if (Locale::getDefault() == Locale("te_IN")) {
Locale::setDefault(Locale("en_US"), status);
}
testTag("only_in_Root", TRUE, FALSE, FALSE);
testTag("only_in_te", FALSE, TRUE, FALSE);
testTag("only_in_te_IN", FALSE, FALSE, TRUE);
testTag("in_Root_te", TRUE, TRUE, FALSE);
testTag("in_Root_te_te_IN", TRUE, TRUE, TRUE);
testTag("in_Root_te_IN", TRUE, FALSE, TRUE);
testTag("in_te_te_IN", FALSE, TRUE, TRUE);
testTag("nonexistent", FALSE, FALSE, FALSE);
logln("Passed: %d\nFailed: %d", pass, fail);
/* Restore the default locale for the other tests. */
Locale::setDefault(originalDefault, status);
}
开发者ID:LocutusOfBorg,项目名称:poedit,代码行数:30,代码来源:restsnew.cpp
示例5: ucal_open
U_CAPI UCalendar* U_EXPORT2
ucal_open( const UChar* zoneID,
int32_t len,
const char* locale,
UCalendarType caltype,
UErrorCode* status)
{
if(U_FAILURE(*status)) return 0;
TimeZone* zone = (zoneID==NULL) ? TimeZone::createDefault()
: _createTimeZone(zoneID, len, status);
if (U_FAILURE(*status)) {
return NULL;
}
if ( caltype == UCAL_GREGORIAN ) {
char localeBuf[ULOC_LOCALE_IDENTIFIER_CAPACITY];
if ( locale == NULL ) {
locale = uloc_getDefault();
}
uprv_strncpy(localeBuf, locale, ULOC_LOCALE_IDENTIFIER_CAPACITY);
uloc_setKeywordValue("calendar", "gregorian", localeBuf, ULOC_LOCALE_IDENTIFIER_CAPACITY, status);
if (U_FAILURE(*status)) {
return NULL;
}
return (UCalendar*)Calendar::createInstance(zone, Locale(localeBuf), *status);
}
return (UCalendar*)Calendar::createInstance(zone, Locale(locale), *status);
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:31,代码来源:ucal.cpp
示例6: udat_open
U_CAPI UDateFormat* U_EXPORT2
udat_open(UDateFormatStyle timeStyle,
UDateFormatStyle dateStyle,
const char *locale,
const UChar *tzID,
int32_t tzIDLength,
const UChar *pattern,
int32_t patternLength,
UErrorCode *status)
{
DateFormat *fmt;
if(U_FAILURE(*status)) {
return 0;
}
if(gOpener!=NULL) { // if it's registered
fmt = (DateFormat*) (*gOpener)(timeStyle,dateStyle,locale,tzID,tzIDLength,pattern,patternLength,status);
if(fmt!=NULL) {
return (UDateFormat*)fmt;
} // else fall through.
}
if(timeStyle != UDAT_PATTERN) {
if(locale == 0) {
fmt = DateFormat::createDateTimeInstance((DateFormat::EStyle)dateStyle,
(DateFormat::EStyle)timeStyle);
}
else {
fmt = DateFormat::createDateTimeInstance((DateFormat::EStyle)dateStyle,
(DateFormat::EStyle)timeStyle,
Locale(locale));
}
}
else {
UnicodeString pat((UBool)(patternLength == -1), pattern, patternLength);
if(locale == 0) {
fmt = new SimpleDateFormat(pat, *status);
}
else {
fmt = new SimpleDateFormat(pat, Locale(locale), *status);
}
}
if(fmt == 0) {
*status = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
if(tzID != 0) {
TimeZone *zone = TimeZone::createTimeZone(UnicodeString((UBool)(tzIDLength == -1), tzID, tzIDLength));
if(zone == 0) {
*status = U_MEMORY_ALLOCATION_ERROR;
delete fmt;
return 0;
}
fmt->adoptTimeZone(zone);
}
return (UDateFormat*)fmt;
}
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:59,代码来源:icu52_i18n_udat.cpp
示例7: ubrk_open
//----------------------------------------------------------------------------------------
//
// ubrk_open Create a canned type of break iterator based on type (word, line, etc.)
// and locale.
//
//----------------------------------------------------------------------------------------
U_CAPI UBreakIterator* U_EXPORT2
ubrk_open(UBreakIteratorType type,
const char *locale,
const UChar *text,
int32_t textLength,
UErrorCode *status)
{
if(U_FAILURE(*status)) return 0;
BreakIterator *result = 0;
switch(type) {
case UBRK_CHARACTER:
result = BreakIterator::createCharacterInstance(Locale(locale), *status);
break;
case UBRK_WORD:
result = BreakIterator::createWordInstance(Locale(locale), *status);
break;
case UBRK_LINE:
result = BreakIterator::createLineInstance(Locale(locale), *status);
break;
case UBRK_SENTENCE:
result = BreakIterator::createSentenceInstance(Locale(locale), *status);
break;
case UBRK_TITLE:
result = BreakIterator::createTitleInstance(Locale(locale), *status);
break;
}
// check for allocation error
if (U_FAILURE(*status)) {
return 0;
}
if(result == 0) {
*status = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
if (text != NULL) {
UCharCharacterIterator *iter = 0;
iter = new UCharCharacterIterator(text, textLength);
if(iter == 0) {
*status = U_MEMORY_ALLOCATION_ERROR;
delete result;
return 0;
}
result->adoptText(iter);
}
return (UBreakIterator*)result;
}
开发者ID:S0043640wipro,项目名称:RiCRiPInt,代码行数:63,代码来源:ubrk.cpp
示例8: AddressStringStream
void MallocState::print(llvm::raw_ostream &Out,
seec::util::IndentationGuide &Indentation) const
{
std::string AddressString;
{
llvm::raw_string_ostream AddressStringStream(AddressString);
seec::util::write_hex_padded(AddressStringStream, this->getAddress());
}
auto const LazyDescription =
seec::LazyMessageByRef::create("SeeCClang",
{"states", "MallocState"},
std::make_pair("size",
int64_t(this->getSize())),
std::make_pair("address",
AddressString.c_str()));
UErrorCode ICUStatus = U_ZERO_ERROR;
auto const Description = LazyDescription->get(ICUStatus, Locale());
if (U_FAILURE(ICUStatus))
return;
Out << Indentation.getString() << Description << "\n";
auto const Mapping = this->getAllocatorInstMapping();
if (auto const Stmt = Mapping.getStmt()) {
Indentation.indent();
auto const &AST = Mapping.getAST()->getASTUnit();
auto const &SrcManager = AST.getSourceManager();
auto const LocStart = Stmt->getLocStart();
auto const Filename = SrcManager.getFilename(LocStart);
auto const Line = SrcManager.getSpellingLineNumber(LocStart);
auto const Column = SrcManager.getSpellingColumnNumber(LocStart);
auto const LazyLocation =
seec::LazyMessageByRef::create("SeeCClang",
{"states", "MallocStateAllocatedAt"},
std::make_pair("filename",
Filename.str().c_str()),
std::make_pair("line", int64_t(Line)),
std::make_pair("column", int64_t(Column)));
auto const Location = LazyLocation->get(ICUStatus, Locale());
if (U_SUCCESS(ICUStatus))
Out << Indentation.getString() << Location << "\n";
Indentation.unindent();
}
}
开发者ID:mheinsen,项目名称:seec,代码行数:54,代码来源:MappedMallocState.cpp
示例9: ubrk_open
//------------------------------------------------------------------------------
//
// ubrk_open Create a canned type of break iterator based on type (word, line, etc.)
// and locale.
//
//------------------------------------------------------------------------------
U_CAPI UBreakIterator* U_EXPORT2
ubrk_open(UBreakIteratorType type,
const char *locale,
const UChar *text,
int32_t textLength,
UErrorCode *status)
{
if(U_FAILURE(*status)) return 0;
BreakIterator *result = 0;
switch(type) {
case UBRK_CHARACTER:
result = BreakIterator::createCharacterInstance(Locale(locale), *status);
break;
case UBRK_WORD:
result = BreakIterator::createWordInstance(Locale(locale), *status);
break;
case UBRK_LINE:
result = BreakIterator::createLineInstance(Locale(locale), *status);
break;
case UBRK_SENTENCE:
result = BreakIterator::createSentenceInstance(Locale(locale), *status);
break;
case UBRK_TITLE:
result = BreakIterator::createTitleInstance(Locale(locale), *status);
break;
default:
*status = U_ILLEGAL_ARGUMENT_ERROR;
}
// check for allocation error
if (U_FAILURE(*status)) {
return 0;
}
if(result == 0) {
*status = U_MEMORY_ALLOCATION_ERROR;
return 0;
}
UBreakIterator *uBI = (UBreakIterator *)result;
if (text != NULL) {
ubrk_setText(uBI, text, textLength, status);
}
return uBI;
}
开发者ID:ONLYOFFICE,项目名称:core,代码行数:60,代码来源:ubrk.cpp
示例10: initAvailableLocaleList
static void U_CALLCONV
initAvailableLocaleList(UErrorCode &status) {
U_ASSERT(availableLocaleListCount == 0);
U_ASSERT(availableLocaleList == NULL);
// for now, there is a hardcoded list, so just walk through that list and set it up.
UResourceBundle *index = NULL;
UResourceBundle installed;
int32_t i = 0;
ures_initStackObject(&installed);
index = ures_openDirect(U_ICUDATA_COLL, "res_index", &status);
ures_getByKey(index, "InstalledLocales", &installed, &status);
if(U_SUCCESS(status)) {
availableLocaleListCount = ures_getSize(&installed);
availableLocaleList = new Locale[availableLocaleListCount];
if (availableLocaleList != NULL) {
ures_resetIterator(&installed);
while(ures_hasNext(&installed)) {
const char *tempKey = NULL;
ures_getNextString(&installed, NULL, &tempKey, &status);
availableLocaleList[i++] = Locale(tempKey);
}
}
U_ASSERT(availableLocaleListCount == i);
ures_close(&installed);
}
ures_close(index);
ucln_i18n_registerCleanup(UCLN_I18N_COLLATOR, collator_cleanup);
}
开发者ID:cyrusimap,项目名称:icu4c,代码行数:31,代码来源:coll.cpp
示例11: Locale
/* When the default locale is tr, make sure that the pattern can still be parsed. */
void TestMessageFormat::TestTurkishCasing()
{
UErrorCode err = U_ZERO_ERROR;
Locale saveDefaultLocale;
Locale::setDefault( Locale("tr"), err );
Formattable arguments[] = {
(int32_t)7,
Formattable(UDate(8.71068e+011), Formattable::kIsDate),
"a disturbance in the Force"
};
UnicodeString result;
result = MessageFormat::format(
"At {1,TIME} on {1,DATE,SHORT}, there was {2} on planet {0,NUMBER,INTEGER}.",
arguments,
3,
result,
err);
if (U_FAILURE(err)) {
errln("TestTurkishCasing #1 with error code %s", u_errorName(err));
return;
}
const UnicodeString expected(
"At 12:20:00 on 08.08.1997, there was a disturbance in the Force on planet 7.", "");
if (result != expected) {
errln("TestTurkishCasing failed on test");
errln( UnicodeString(" Result: ") + result );
errln( UnicodeString(" Expected: ") + expected );
}
Locale::setDefault( saveDefaultLocale, err );
}
开发者ID:Katarzynasrom,项目名称:patch-hosting-for-android-x86-support,代码行数:35,代码来源:tmsgfmt.cpp
示例12: UMTX_CHECK
void
EthiopicCalendar::initializeSystemDefaultCentury()
{
// lazy-evaluate systemDefaultCenturyStart
UBool needsUpdate;
UMTX_CHECK(NULL, (fgSystemDefaultCenturyStart == fgSystemDefaultCentury), needsUpdate);
if (!needsUpdate) {
return;
}
UErrorCode status = U_ZERO_ERROR;
EthiopicCalendar calendar(Locale("@calendar=ethiopic"), status);
if (U_SUCCESS(status)) {
calendar.setTime(Calendar::getNow(), status);
calendar.add(UCAL_YEAR, -80, status);
UDate newStart = calendar.getTime(status);
int32_t newYear = calendar.get(UCAL_YEAR, status);
{
umtx_lock(NULL);
fgSystemDefaultCenturyStartYear = newYear;
fgSystemDefaultCenturyStart = newStart;
umtx_unlock(NULL);
}
}
// We have no recourse upon failure unless we want to propagate the failure
// out.
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:29,代码来源:ethpccal.cpp
示例13: _findMetaData
/**
* Internal function to look up currency data. Result is an array of
* two integers. The first is the fraction digits. The second is the
* rounding increment, or 0 if none. The rounding increment is in
* units of 10^(-fraction_digits).
*/
static const int32_t*
_findMetaData(const UChar* currency) {
// Get CurrencyMeta resource out of root locale file. [This may
// move out of the root locale file later; if it does, update this
// code.]
UErrorCode ec = U_ZERO_ERROR;
ResourceBundle currencyMeta =
ResourceBundle((char*)0, Locale(""), ec).get(CURRENCY_META, ec);
if (U_FAILURE(ec)) {
// Config/build error; return hard-coded defaults
return LAST_RESORT_DATA;
}
// Look up our currency, or if that's not available, then DEFAULT
char buf[ISO_COUNTRY_CODE_LENGTH+1];
ResourceBundle rb = currencyMeta.get(myUCharsToChars(buf, currency), ec);
if (U_FAILURE(ec)) {
rb = currencyMeta.get(DEFAULT_META, ec);
if (U_FAILURE(ec)) {
// Config/build error; return hard-coded defaults
return LAST_RESORT_DATA;
}
}
int32_t len;
const int32_t *data = rb.getIntVector(len, ec);
if (U_FAILURE(ec) || len < 2) {
// Config/build error; return hard-coded defaults
return LAST_RESORT_DATA;
}
return data;
}
开发者ID:gitpan,项目名称:ponie,代码行数:41,代码来源:ucurr.cpp
示例14: failure
void DateFormatRoundTripTest::TestDateFormatRoundTrip()
{
UErrorCode status = U_ZERO_ERROR;
getFieldCal = Calendar::createInstance(status);
failure(status, "Calendar::createInstance");
if(!assertSuccess("trying to construct", status))return;
int32_t locCount = 0;
const Locale *avail = DateFormat::getAvailableLocales(locCount);
logln("DateFormat available locales: %d", locCount);
if(quick) {
SPARSENESS = 18;
logln("Quick mode: only testing SPARSENESS = 18");
}
TimeZone *tz = TimeZone::createDefault();
UnicodeString temp;
logln("Default TimeZone: " + tz->getID(temp));
delete tz;
#ifdef TEST_ONE_LOC // define this to just test ONE locale.
Locale loc(TEST_ONE_LOC);
test(loc);
#if INFINITE
for(;;) {
test(loc);
}
#endif
#else
# if INFINITE
// Special infinite loop test mode for finding hard to reproduce errors
Locale loc = Locale::getDefault();
logln("ENTERING INFINITE TEST LOOP FOR Locale: " + loc.getDisplayName(temp));
for(;;)
test(loc);
# else
test(Locale::getDefault());
#if 1
// installed locales
for (int i=0; i < locCount; ++i) {
test(avail[i]);
}
#endif
#if 1
// special locales
int32_t jCount = CalendarTest::testLocaleCount();
for (int32_t j=0; j < jCount; ++j) {
test(Locale(CalendarTest::testLocaleID(j)));
}
#endif
# endif
#endif
delete getFieldCal;
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:60,代码来源:dtfmtrtts.cpp
示例15: ucasemap_utf8ToTitle
U_CAPI int32_t U_EXPORT2
ucasemap_utf8ToTitle(UCaseMap *csm,
char *dest, int32_t destCapacity,
const char *src, int32_t srcLength,
UErrorCode *pErrorCode) {
if (U_FAILURE(*pErrorCode)) {
return 0;
}
UText utext=UTEXT_INITIALIZER;
utext_openUTF8(&utext, (const char *)src, srcLength, pErrorCode);
if(csm->iter==NULL) {
csm->iter=BreakIterator::createWordInstance(Locale(csm->locale), *pErrorCode);
}
if (U_FAILURE(*pErrorCode)) {
return 0;
}
csm->iter->setText(&utext, *pErrorCode);
int32_t length=ucasemap_mapUTF8(
csm->caseLocale, csm->options, csm->iter,
(uint8_t *)dest, destCapacity,
(const uint8_t *)src, srcLength,
ucasemap_internalUTF8ToTitle, pErrorCode);
utext_close(&utext);
return length;
}
开发者ID:cyrusimap,项目名称:icu4c,代码行数:25,代码来源:ucasemap_titlecase_brkiter.cpp
示例16: u_strToTitle
U_NAMESPACE_USE
/* functions available in the common library (for unistr_case.cpp) */
/* public API functions */
U_CAPI int32_t U_EXPORT2
u_strToTitle(UChar *dest, int32_t destCapacity,
const UChar *src, int32_t srcLength,
UBreakIterator *titleIter,
const char *locale,
UErrorCode *pErrorCode) {
LocalPointer<BreakIterator> ownedIter;
BreakIterator *iter;
if(titleIter!=NULL) {
iter=reinterpret_cast<BreakIterator *>(titleIter);
} else {
iter=BreakIterator::createWordInstance(Locale(locale), *pErrorCode);
ownedIter.adoptInstead(iter);
}
if(U_FAILURE(*pErrorCode)) {
return 0;
}
UnicodeString s(srcLength<0, src, srcLength);
iter->setText(s);
return ustrcase_mapWithOverlap(
ustrcase_getCaseLocale(locale), 0, iter,
dest, destCapacity,
src, srcLength,
ustrcase_internalToTitle, *pErrorCode);
}
开发者ID:BazisSoft,项目名称:node-delphi,代码行数:31,代码来源:ustr_titlecase_brkiter.cpp
示例17: IslamicCalendar
void
IslamicCalendar::initializeSystemDefaultCentury()
{
// initialize systemDefaultCentury and systemDefaultCenturyYear based
// on the current time. They'll be set to 80 years before
// the current time.
// No point in locking as it should be idempotent.
if (fgSystemDefaultCenturyStart == fgSystemDefaultCentury)
{
UErrorCode status = U_ZERO_ERROR;
Calendar *calendar = new IslamicCalendar(Locale("[email protected]=islamic-civil"),status);
if (calendar != NULL && U_SUCCESS(status))
{
calendar->setTime(Calendar::getNow(), status);
calendar->add(UCAL_YEAR, -80, status);
UDate newStart = calendar->getTime(status);
int32_t newYear = calendar->get(UCAL_YEAR, status);
{
Mutex m;
fgSystemDefaultCenturyStart = newStart;
fgSystemDefaultCenturyStartYear = newYear;
}
delete calendar;
}
// We have no recourse upon failure unless we want to propagate the failure
// out.
}
}
开发者ID:andrewleech,项目名称:firebird,代码行数:28,代码来源:islamcal.cpp
示例18: CHECK
// Verify that Gregorian works like Gregorian
void IntlCalendarTest::TestGregorian() {
UDate timeA = Calendar::getNow();
int32_t data[] = {
GregorianCalendar::AD, 1868, 1868, UCAL_SEPTEMBER, 8,
GregorianCalendar::AD, 1868, 1868, UCAL_SEPTEMBER, 9,
GregorianCalendar::AD, 1869, 1869, UCAL_JUNE, 4,
GregorianCalendar::AD, 1912, 1912, UCAL_JULY, 29,
GregorianCalendar::AD, 1912, 1912, UCAL_JULY, 30,
GregorianCalendar::AD, 1912, 1912, UCAL_AUGUST, 1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
};
Calendar *cal;
UErrorCode status = U_ZERO_ERROR;
cal = Calendar::createInstance(/*"de_DE", */ status);
CHECK(status, UnicodeString("Creating de_CH calendar"));
// Sanity check the calendar
UDate timeB = Calendar::getNow();
UDate timeCal = cal->getTime(status);
if(!(timeA <= timeCal) || !(timeCal <= timeB)) {
errln((UnicodeString)"Error: Calendar time " + timeCal +
" is not within sampled times [" + timeA + " to " + timeB + "]!");
}
// end sanity check
// Note, the following is a good way to test the sanity of the constructed calendars,
// using Collation as a delay-loop:
//
// $ intltest format/IntlCalendarTest collate/G7CollationTest format/IntlCalendarTest
quasiGregorianTest(*cal,Locale("fr_FR"),data);
delete cal;
}
开发者ID:ilseokhan,项目名称:platform_external_icu4c,代码行数:35,代码来源:incaltst.cpp
示例19: calendar
void
TaiwanCalendar::initializeSystemDefaultCentury()
{
// initialize systemDefaultCentury and systemDefaultCenturyYear based
// on the current time. They'll be set to 80 years before
// the current time.
UErrorCode status = U_ZERO_ERROR;
TaiwanCalendar calendar(Locale("@calendar=roc"),status);
if (U_SUCCESS(status))
{
calendar.setTime(Calendar::getNow(), status);
calendar.add(UCAL_YEAR, -80, status);
UDate newStart = calendar.getTime(status);
int32_t newYear = calendar.get(UCAL_YEAR, status);
umtx_lock(NULL);
if (fgSystemDefaultCenturyStart == fgSystemDefaultCentury)
{
fgSystemDefaultCenturyStartYear = newYear;
fgSystemDefaultCenturyStart = newStart;
}
umtx_unlock(NULL);
}
// We have no recourse upon failure unless we want to propagate the failure
// out.
}
开发者ID:00zhengfu00,项目名称:third_party,代码行数:25,代码来源:taiwncal.cpp
示例20: converter
status_t
BLanguage::GetName(BString& name, const BLanguage* displayLanguage) const
{
status_t status = B_OK;
BString appLanguage;
if (displayLanguage == NULL) {
BMessage preferredLanguage;
status = BLocaleRoster::Default()->GetPreferredLanguages(
&preferredLanguage);
if (status == B_OK)
status = preferredLanguage.FindString("language", 0, &appLanguage);
} else {
appLanguage = displayLanguage->Code();
}
if (status == B_OK) {
UnicodeString string;
fICULocale->getDisplayName(Locale(appLanguage), string);
name.Truncate(0);
BStringByteSink converter(&name);
string.toUTF8(converter);
}
return status;
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:27,代码来源:Language.cpp
注:本文中的Locale函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论