本文整理汇总了C++中UnicodeString::charAt方法的典型用法代码示例。如果您正苦于以下问题:C++ UnicodeString::charAt方法的具体用法?C++ UnicodeString::charAt怎么用?C++ UnicodeString::charAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnicodeString
的用法示例。
在下文中一共展示了UnicodeString::charAt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseInteger
U_NAMESPACE_BEGIN
/**
* Parse an integer at pos, either of the form \d+ or of the form
* 0x[0-9A-Fa-f]+ or 0[0-7]+, that is, in standard decimal, hex,
* or octal format.
* @param pos INPUT-OUTPUT parameter. On input, the first
* character to parse. On output, the character after the last
* parsed character.
*/
int32_t ICU_Utility::parseInteger(const UnicodeString& rule, int32_t& pos, int32_t limit) {
int32_t count = 0;
int32_t value = 0;
int32_t p = pos;
int8_t radix = 10;
if (p < limit && rule.charAt(p) == 48 /*0*/) {
if (p+1 < limit && (rule.charAt(p+1) == 0x78 /*x*/ || rule.charAt(p+1) == 0x58 /*X*/)) {
p += 2;
radix = 16;
}
else {
p++;
count = 1;
radix = 8;
}
}
while (p < limit) {
int32_t d = u_digit(rule.charAt(p++), radix);
if (d < 0) {
--p;
break;
}
++count;
int32_t v = (value * radix) + d;
if (v <= value) {
// If there are too many input digits, at some point
// the value will go negative, e.g., if we have seen
// "0x8000000" already and there is another '0', when
// we parse the next 0 the value will go negative.
return 0;
}
value = v;
}
if (count > 0) {
pos = p;
}
return value;
}
示例2: while
//
// replaceCharRefs
//
// replace the char entities < & { ካ etc. in a string
// with the corresponding actual character.
//
void
UXMLParser::replaceCharRefs(UnicodeString &s, UErrorCode &status) {
UnicodeString result;
UnicodeString replacement;
int i;
mAmps.reset(s);
// See the initialization for the regex matcher mAmps.
// Which entity we've matched is determined by which capture group has content,
// which is flaged by start() of that group not being -1.
while (mAmps.find()) {
if (mAmps.start(1, status) != -1) {
replacement.setTo((UChar)x_AMP);
} else if (mAmps.start(2, status) != -1) {
replacement.setTo((UChar)x_LT);
} else if (mAmps.start(3, status) != -1) {
replacement.setTo((UChar)x_GT);
} else if (mAmps.start(4, status) != -1) {
replacement.setTo((UChar)x_APOS);
} else if (mAmps.start(5, status) != -1) {
replacement.setTo((UChar)x_QUOT);
} else if (mAmps.start(6, status) != -1) {
UnicodeString hexString = mAmps.group(6, status);
UChar32 val = 0;
for (i=0; i<hexString.length(); i++) {
val = (val << 4) + u_digit(hexString.charAt(i), 16);
}
// TODO: some verification that the character is valid
replacement.setTo(val);
} else if (mAmps.start(7, status) != -1) {
UnicodeString decimalString = mAmps.group(7, status);
UChar32 val = 0;
for (i=0; i<decimalString.length(); i++) {
val = val*10 + u_digit(decimalString.charAt(i), 10);
}
// TODO: some verification that the character is valid
replacement.setTo(val);
} else {
// An unrecognized &entity; Leave it alone.
// TODO: check that it really looks like an entity, and is not some
// random & in the text.
replacement = mAmps.group((int32_t)0, status);
}
mAmps.appendReplacement(result, replacement, status);
}
mAmps.appendTail(result);
s = result;
}
示例3: setCharField
static void setCharField(JNIEnv* env, jobject obj, const char* fieldName, const UnicodeString& value) {
if (value.length() == 0) {
return;
}
jfieldID fid = env->GetFieldID(JniConstants::localeDataClass, fieldName, "C");
env->SetCharField(obj, fid, value.charAt(0));
}
示例4:
UBool
LocaleUtility::isFallbackOf(const UnicodeString& root, const UnicodeString& child)
{
return child.indexOf(root) == 0 &&
(child.length() == root.length() ||
child.charAt(root.length()) == UNDERSCORE_CHAR);
}
示例5: parseHex
static UnicodeString parseHex(const UnicodeString &in) {
// Convert a series of hex numbers in a Unicode String to a string with the
// corresponding characters.
// The conversion is _really_ annoying. There must be some function to just do it.
UnicodeString result;
UChar32 cc = 0;
for (int32_t i=0; i<in.length(); i++) {
UChar c = in.charAt(i);
if (c == 0x20) { // Space
if (cc > 0) {
result.append(cc);
cc = 0;
}
} else if (c>=0x30 && c<=0x39) {
cc = (cc<<4) + (c - 0x30);
} else if ((c>=0x41 && c<=0x46) || (c>=0x61 && c<=0x66)) {
cc = (cc<<4) + (c & 0x0f)+9;
}
// else do something with bad input.
}
if (cc > 0) {
result.append(cc);
}
return result;
}
示例6: fixQuotes
// fixQuotes unescapes single quotes. Don''t -> Don't. Letter 'j' -> Letter j.
// Modifies s in place.
static void fixQuotes(UnicodeString& s) {
QuoteState state = OUTSIDE;
int32_t len = s.length();
int32_t dest = 0;
for (int32_t i = 0; i < len; ++i) {
UChar ch = s.charAt(i);
if (ch == u_apos) {
if (state == INSIDE_EMPTY) {
s.setCharAt(dest, ch);
++dest;
}
} else {
s.setCharAt(dest, ch);
++dest;
}
// Update state
switch (state) {
case OUTSIDE:
state = ch == u_apos ? INSIDE_EMPTY : OUTSIDE;
break;
case INSIDE_EMPTY:
case INSIDE_FULL:
state = ch == u_apos ? OUTSIDE : INSIDE_FULL;
break;
default:
break;
}
}
s.truncate(dest);
}
示例7: addRun
void TextGroup::addRun(const UnicodeString &input, UBiDiDirection direction, int32_t start, int32_t end)
{
std::string text;
input.tempSubString(start, end - start).toUTF8String(text);
printf("Hominlinx-->======TextGroup::addRun[%s]==== %d\n",text.c_str(), input.charAt(0) );
runs_.emplace_back(text, script_, lang_, uciDirectionToHB(direction));
}
示例8: TestReplaceable
TestReplaceable (const UnicodeString& text,
const UnicodeString& newStyles) {
chars = text;
UnicodeString s;
for (int i = 0; i < text.length(); ++i) {
if (i < newStyles.length()) {
s.append(newStyles.charAt(i));
} else {
if (text.charAt(i) == NO_STYLE_MARK) {
s.append(NO_STYLE);
} else {
s.append((UChar)(i + 0x0031));
}
}
}
this->styles = s;
}
示例9: parsePattern
/**
* Parse a pattern string starting at offset pos. Keywords are
* matched case-insensitively. Spaces may be skipped and may be
* optional or required. Integer values may be parsed, and if
* they are, they will be returned in the given array. If
* successful, the offset of the next non-space character is
* returned. On failure, -1 is returned.
* @param pattern must only contain lowercase characters, which
* will match their uppercase equivalents as well. A space
* character matches one or more required spaces. A '~' character
* matches zero or more optional spaces. A '#' character matches
* an integer and stores it in parsedInts, which the caller must
* ensure has enough capacity.
* @param parsedInts array to receive parsed integers. Caller
* must ensure that parsedInts.length is >= the number of '#'
* signs in 'pattern'.
* @return the position after the last character parsed, or -1 if
* the parse failed
*/
int32_t ICU_Utility::parsePattern(const UnicodeString& rule, int32_t pos, int32_t limit,
const UnicodeString& pattern, int32_t* parsedInts) {
// TODO Update this to handle surrogates
int32_t p;
int32_t intCount = 0; // number of integers parsed
for (int32_t i=0; i<pattern.length(); ++i) {
UChar cpat = pattern.charAt(i);
UChar c;
switch (cpat) {
case 32 /*' '*/:
if (pos >= limit) {
return -1;
}
c = rule.charAt(pos++);
if (!PatternProps::isWhiteSpace(c)) {
return -1;
}
// FALL THROUGH to skipWhitespace
U_FALLTHROUGH;
case 126 /*'~'*/:
pos = skipWhitespace(rule, pos);
break;
case 35 /*'#'*/:
p = pos;
parsedInts[intCount++] = parseInteger(rule, p, limit);
if (p == pos) {
// Syntax error; failed to parse integer
return -1;
}
pos = p;
break;
default:
if (pos >= limit) {
return -1;
}
c = (UChar) u_tolower(rule.charAt(pos++));
if (c != cpat) {
return -1;
}
break;
}
}
return pos;
}
示例10: classifyCharacter
UBool
SelectFormat::checkValidKeyword(const UnicodeString& argKeyword ) const{
int32_t len = argKeyword.length();
if (len < 1){
return FALSE;
}
CharacterClass type = classifyCharacter(argKeyword.charAt(0));
if( type != tStartKeyword ){
return FALSE;
}
for (int32_t i = 0; i < argKeyword.length(); ++i) {
type = classifyCharacter(argKeyword.charAt(i));
if( type != tStartKeyword && type != tContinueKeyword ){
return FALSE;
}
}
return TRUE;
}
示例11: if
int32_t
MessagePattern::parseArgNumber(const UnicodeString &s, int32_t start, int32_t limit) {
// If the identifier contains only ASCII digits, then it is an argument _number_
// and must not have leading zeros (except "0" itself).
// Otherwise it is an argument _name_.
if(start>=limit) {
return UMSGPAT_ARG_NAME_NOT_VALID;
}
int32_t number;
// Defer numeric errors until we know there are only digits.
UBool badNumber;
UChar c=s.charAt(start++);
if(c==0x30) {
if(start==limit) {
return 0;
} else {
number=0;
badNumber=TRUE; // leading zero
}
} else if(0x31<=c && c<=0x39) {
number=c-0x30;
badNumber=FALSE;
} else {
return UMSGPAT_ARG_NAME_NOT_NUMBER;
}
while(start<limit) {
c=s.charAt(start++);
if(0x30<=c && c<=0x39) {
if(number>=INT32_MAX/10) {
badNumber=TRUE; // overflow
}
number=number*10+(c-0x30);
} else {
return UMSGPAT_ARG_NAME_NOT_NUMBER;
}
}
// There are only ASCII digits.
if(badNumber) {
return UMSGPAT_ARG_NAME_NOT_VALID;
} else {
return number;
}
}
示例12: parseInteger
U_NAMESPACE_BEGIN
int32_t ICU_Utility::parseInteger(const UnicodeString& rule, int32_t& pos, int32_t limit) {
int32_t count = 0;
int32_t value = 0;
int32_t p = pos;
int8_t radix = 10;
if (p < limit && rule.charAt(p) == 48 /*0*/) {
if (p+1 < limit && (rule.charAt(p+1) == 0x78 /*x*/ || rule.charAt(p+1) == 0x58 /*X*/)) {
p += 2;
radix = 16;
}
else {
p++;
count = 1;
radix = 8;
}
}
while (p < limit) {
int32_t d = u_digit(rule.charAt(p++), radix);
if (d < 0) {
--p;
break;
}
++count;
int32_t v = (value * radix) + d;
if (v <= value) {
// If there are too many input digits, at some point
// the value will go negative, e.g., if we have seen
// "0x8000000" already and there is another '0', when
// we parse the next 0 the value will go negative.
return 0;
}
value = v;
}
if (count > 0) {
pos = p;
}
return value;
}
示例13: checkEqual
UBool checkEqual(const PluralRules &test, char *result, int32_t max) {
UnicodeString key;
UBool isEqual = TRUE;
for (int32_t i=0; i<max; ++i) {
key= test.select(i);
if ( key.charAt(0)!=result[i] ) {
isEqual = FALSE;
}
}
return isEqual;
}
示例14: RBBI_DEBUG_printUnicodeString
U_CFUNC void RBBI_DEBUG_printUnicodeString(const UnicodeString &s, int minWidth)
{
int i;
for (i=0; i<s.length(); i++) {
RBBIDebugPrintf("%c", s.charAt(i));
// putc(s.charAt(i), stdout);
}
for (i=s.length(); i<minWidth; i++) {
RBBIDebugPrintf(" ");
}
}
示例15: TestMFCCompatibility
void UObjectTest::TestMFCCompatibility() {
#if U_HAVE_DEBUG_LOCATION_NEW
/* Make sure that it compiles with MFC's debuggable new usage. */
UnicodeString *str = new(__FILE__, __LINE__) UnicodeString();
str->append((UChar)0x0040); // Is it usable?
if(str->charAt(0) != 0x0040) {
errln("debug new doesn't work.");
}
UnicodeString::operator delete(str, __FILE__, __LINE__);
#endif
}