本文整理汇总了C++中UnicodeString::caseCompare方法的典型用法代码示例。如果您正苦于以下问题:C++ UnicodeString::caseCompare方法的具体用法?C++ UnicodeString::caseCompare怎么用?C++ UnicodeString::caseCompare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnicodeString
的用法示例。
在下文中一共展示了UnicodeString::caseCompare方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getDisplayName
UnicodeString& getDisplayName(const UnicodeString& id, const Locale& locale, UnicodeString& result) const
{
UnicodeString prefix = "";
UnicodeString suffix = "";
UnicodeString ls = locale.getName();
if (LocaleUtility::isFallbackOf(californio, ls)) {
if (!ls.caseCompare(valley, 0)) {
prefix = "Like, you know, it's so totally ";
} else if (!ls.caseCompare(surfer, 0)) {
prefix = "Dude, it's ";
} else if (!ls.caseCompare(geek, 0)) {
prefix = "I'd estimate it is approximately ";
} else {
prefix = "Huh? Maybe ";
}
}
if (LocaleUtility::isFallbackOf(californio, id)) {
if (!id.caseCompare(valley, 0)) {
suffix = "like the Valley, you know? Let's go to the mall!";
} else if (!id.caseCompare(surfer, 0)) {
suffix = "time to hit those gnarly waves, Dude!!!";
} else if (!id.caseCompare(geek, 0)) {
suffix = "all systems go. T-Minus 9, 8, 7...";
} else {
suffix = "No Habla Englais";
}
} else {
suffix = ICUResourceBundleFactory::getDisplayName(id, locale, result);
}
result = prefix + suffix;
return result;
}
示例2: wxDynamicCast
void t4p::PhpCodeCompletionProviderClass::OnAutoCompletionSelected(wxStyledTextEvent& event) {
wxStyledTextCtrl* txtCtrl = wxDynamicCast(event.GetEventObject(), wxStyledTextCtrl);
if (!txtCtrl) {
return;
}
t4p::CodeControlClass* ctrl = (t4p::CodeControlClass*)txtCtrl;
if (!AutoCompletionResourceMatches.empty()) {
UnicodeString selected = t4p::WxToIcu(event.GetText());
bool handled = false;
for (size_t i = 0; i < AutoCompletionResourceMatches.size(); ++i) {
t4p::PhpTagClass res = AutoCompletionResourceMatches[i];
if (res.Identifier == selected) {
// user had selected a function /method name; let's add the
// parenthesis and show the call tip
ctrl->AutoCompCancel();
wxString selected = event.GetText();
int startPos = ctrl->WordStartPosition(ctrl->GetCurrentPos(), true);
ctrl->SetSelection(startPos, ctrl->GetCurrentPos());
wxString status;
if ((t4p::PhpTagClass::FUNCTION == res.Type || t4p::PhpTagClass::METHOD == res.Type) && !res.HasParameters()) {
ctrl->ReplaceSelection(selected + wxT("()"));
ctrl->HandleCallTip(0, true);
} else if (t4p::PhpTagClass::FUNCTION == res.Type || t4p::PhpTagClass::METHOD == res.Type) {
ctrl->ReplaceSelection(selected + wxT("("));
ctrl->HandleCallTip(0, true);
} else {
ctrl->ReplaceSelection(selected);
}
handled = true;
break;
}
}
if (!handled) {
// complete the PHP alternative syntax for control structures
// ie endif endwhile endfor endforeach endswitch
// Scintilla cannot handle semicolons in keywords; we will add the semicolon here
if (selected.caseCompare(UNICODE_STRING_SIMPLE("endif"), 0) == 0 ||
selected.caseCompare(UNICODE_STRING_SIMPLE("endwhile"), 0) == 0 ||
selected.caseCompare(UNICODE_STRING_SIMPLE("endfor"), 0) == 0 ||
selected.caseCompare(UNICODE_STRING_SIMPLE("endforeach"), 0) == 0 ||
selected.caseCompare(UNICODE_STRING_SIMPLE("endswitch"), 0) == 0) {
ctrl->AutoCompCancel();
wxString selected = event.GetText();
int startPos = ctrl->WordStartPosition(ctrl->GetCurrentPos(), true);
ctrl->SetSelection(startPos, ctrl->GetCurrentPos());
ctrl->ReplaceSelection(selected + wxT(";"));
}
}
}
}
示例3: registerSpecialInverse
/**
* Register two targets as being inverses of one another. For
* example, calling registerSpecialInverse("NFC", "NFD", TRUE) causes
* Transliterator to form the following inverse relationships:
*
* <pre>NFC => NFD
* Any-NFC => Any-NFD
* NFD => NFC
* Any-NFD => Any-NFC</pre>
*
* (Without the special inverse registration, the inverse of NFC
* would be NFC-Any.) Note that NFD is shorthand for Any-NFD, but
* that the presence or absence of "Any-" is preserved.
*
* <p>The relationship is symmetrical; registering (a, b) is
* equivalent to registering (b, a).
*
* <p>The relevant IDs must still be registered separately as
* factories or classes.
*
* <p>Only the targets are specified. Special inverses always
* have the form Any-Target1 <=> Any-Target2. The target should
* have canonical casing (the casing desired to be produced when
* an inverse is formed) and should contain no whitespace or other
* extraneous characters.
*
* @param target the target against which to register the inverse
* @param inverseTarget the inverse of target, that is
* Any-target.getInverse() => Any-inverseTarget
* @param bidirectional if TRUE, register the reverse relation
* as well, that is, Any-inverseTarget.getInverse() => Any-target
*/
void TransliteratorIDParser::registerSpecialInverse(const UnicodeString& target,
const UnicodeString& inverseTarget,
UBool bidirectional,
UErrorCode &status) {
umtx_initOnce(gSpecialInversesInitOnce, init, status);
if (U_FAILURE(status)) {
return;
}
// If target == inverseTarget then force bidirectional => FALSE
if (bidirectional && 0==target.caseCompare(inverseTarget, U_FOLD_CASE_DEFAULT)) {
bidirectional = FALSE;
}
Mutex lock(&LOCK);
UnicodeString *tempus = new UnicodeString(inverseTarget); // Used for null pointer check before usage.
if (tempus == NULL) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
SPECIAL_INVERSES->put(target, tempus, status);
if (bidirectional) {
tempus = new UnicodeString(target);
if (tempus == NULL) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
SPECIAL_INVERSES->put(inverseTarget, tempus, status);
}
}
示例4: registerIDs
/**
* Registers standard transliterators with the system. Called by
* Transliterator during initialization. Scan all current targets and
* register those that are scripts T as Any-T/V.
*/
void AnyTransliterator::registerIDs() {
UErrorCode ec = U_ZERO_ERROR;
Hashtable seen(TRUE, ec);
int32_t sourceCount = Transliterator::_countAvailableSources();
for (int32_t s=0; s<sourceCount; ++s) {
UnicodeString source;
Transliterator::_getAvailableSource(s, source);
// Ignore the "Any" source
if (source.caseCompare(ANY, 3, 0 /*U_FOLD_CASE_DEFAULT*/) == 0) continue;
int32_t targetCount = Transliterator::_countAvailableTargets(source);
for (int32_t t=0; t<targetCount; ++t) {
UnicodeString target;
Transliterator::_getAvailableTarget(t, source, target);
// Only process each target once
if (seen.geti(target) != 0) continue;
ec = U_ZERO_ERROR;
seen.puti(target, 1, ec);
// Get the script code for the target. If not a script, ignore.
UScriptCode targetScript = scriptNameToCode(target);
if (targetScript == USCRIPT_INVALID_CODE) continue;
int32_t variantCount = Transliterator::_countAvailableVariants(source, target);
// assert(variantCount >= 1);
for (int32_t v=0; v<variantCount; ++v) {
UnicodeString variant;
Transliterator::_getAvailableVariant(v, source, target, variant);
UnicodeString id;
TransliteratorIDParser::STVtoID(UnicodeString(TRUE, ANY, 3), target, variant, id);
ec = U_ZERO_ERROR;
AnyTransliterator* t = new AnyTransliterator(id, target, variant,
targetScript, ec);
if (U_FAILURE(ec)) {
delete t;
} else {
Transliterator::_registerInstance(t);
Transliterator::_registerSpecialInverse(target, UnicodeString(TRUE, NULL_ID, 4), FALSE);
}
}
}
}
}
示例5: registerSpecialInverse
/**
* Register two targets as being inverses of one another. For
* example, calling registerSpecialInverse("NFC", "NFD", TRUE) causes
* Transliterator to form the following inverse relationships:
*
* <pre>NFC => NFD
* Any-NFC => Any-NFD
* NFD => NFC
* Any-NFD => Any-NFC</pre>
*
* (Without the special inverse registration, the inverse of NFC
* would be NFC-Any.) Note that NFD is shorthand for Any-NFD, but
* that the presence or absence of "Any-" is preserved.
*
* <p>The relationship is symmetrical; registering (a, b) is
* equivalent to registering (b, a).
*
* <p>The relevant IDs must still be registered separately as
* factories or classes.
*
* <p>Only the targets are specified. Special inverses always
* have the form Any-Target1 <=> Any-Target2. The target should
* have canonical casing (the casing desired to be produced when
* an inverse is formed) and should contain no whitespace or other
* extraneous characters.
*
* @param target the target against which to register the inverse
* @param inverseTarget the inverse of target, that is
* Any-target.getInverse() => Any-inverseTarget
* @param bidirectional if TRUE, register the reverse relation
* as well, that is, Any-inverseTarget.getInverse() => Any-target
*/
void TransliteratorIDParser::registerSpecialInverse(const UnicodeString& target,
const UnicodeString& inverseTarget,
UBool bidirectional) {
init();
// If target == inverseTarget then force bidirectional => FALSE
if (bidirectional && 0==target.caseCompare(inverseTarget, U_FOLD_CASE_DEFAULT)) {
bidirectional = FALSE;
}
umtx_init(&LOCK);
Mutex lock(&LOCK);
UErrorCode ec = U_ZERO_ERROR;
SPECIAL_INVERSES->put(target, new UnicodeString(inverseTarget), ec);
if (bidirectional) {
SPECIAL_INVERSES->put(inverseTarget, new UnicodeString(target), ec);
}
}
示例6: tzID
UnicodeString&
TZGNCore::formatGenericNonLocationName(const TimeZone& tz, UTimeZoneGenericNameType type, UDate date, UnicodeString& name) const {
U_ASSERT(type == UTZGNM_LONG || type == UTZGNM_SHORT);
name.setToBogus();
const UChar* uID = ZoneMeta::getCanonicalCLDRID(tz);
if (uID == NULL) {
return name;
}
UnicodeString tzID(uID);
// Try to get a name from time zone first
UTimeZoneNameType nameType = (type == UTZGNM_LONG) ? UTZNM_LONG_GENERIC : UTZNM_SHORT_GENERIC;
fTimeZoneNames->getTimeZoneDisplayName(tzID, nameType, name);
if (!name.isEmpty()) {
return name;
}
// Try meta zone
UnicodeString mzID;
fTimeZoneNames->getMetaZoneID(tzID, date, mzID);
if (!mzID.isEmpty()) {
UErrorCode status = U_ZERO_ERROR;
UBool useStandard = FALSE;
int32_t raw, sav;
tz.getOffset(date, FALSE, raw, sav, status);
if (U_FAILURE(status)) {
return name;
}
if (sav == 0) {
useStandard = TRUE;
TimeZone *tmptz = tz.clone();
// Check if the zone actually uses daylight saving time around the time
BasicTimeZone *btz = NULL;
if (dynamic_cast<OlsonTimeZone *>(tmptz) != NULL
|| dynamic_cast<SimpleTimeZone *>(tmptz) != NULL
|| dynamic_cast<RuleBasedTimeZone *>(tmptz) != NULL
|| dynamic_cast<VTimeZone *>(tmptz) != NULL) {
btz = (BasicTimeZone*)tmptz;
}
if (btz != NULL) {
TimeZoneTransition before;
UBool beforTrs = btz->getPreviousTransition(date, TRUE, before);
if (beforTrs
&& (date - before.getTime() < kDstCheckRange)
&& before.getFrom()->getDSTSavings() != 0) {
useStandard = FALSE;
} else {
TimeZoneTransition after;
UBool afterTrs = btz->getNextTransition(date, FALSE, after);
if (afterTrs
&& (after.getTime() - date < kDstCheckRange)
&& after.getTo()->getDSTSavings() != 0) {
useStandard = FALSE;
}
}
} else {
// If not BasicTimeZone... only if the instance is not an ICU's implementation.
// We may get a wrong answer in edge case, but it should practically work OK.
tmptz->getOffset(date - kDstCheckRange, FALSE, raw, sav, status);
if (sav != 0) {
useStandard = FALSE;
} else {
tmptz->getOffset(date + kDstCheckRange, FALSE, raw, sav, status);
if (sav != 0){
useStandard = FALSE;
}
}
if (U_FAILURE(status)) {
delete tmptz;
return name;
}
}
delete tmptz;
}
if (useStandard) {
UTimeZoneNameType stdNameType = (nameType == UTZNM_LONG_GENERIC)
? UTZNM_LONG_STANDARD : UTZNM_SHORT_STANDARD;
UnicodeString stdName;
fTimeZoneNames->getDisplayName(tzID, stdNameType, date, stdName);
if (!stdName.isEmpty()) {
name.setTo(stdName);
// TODO: revisit this issue later
// In CLDR, a same display name is used for both generic and standard
// for some meta zones in some locales. This looks like a data bugs.
// For now, we check if the standard name is different from its generic
// name below.
UnicodeString mzGenericName;
fTimeZoneNames->getMetaZoneDisplayName(mzID, nameType, mzGenericName);
if (stdName.caseCompare(mzGenericName, 0) == 0) {
name.setToBogus();
}
}
//.........这里部分代码省略.........