本文整理汇总了C++中UnicodeString::trim方法的典型用法代码示例。如果您正苦于以下问题:C++ UnicodeString::trim方法的具体用法?C++ UnicodeString::trim怎么用?C++ UnicodeString::trim使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnicodeString
的用法示例。
在下文中一共展示了UnicodeString::trim方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
UnicodeString ascii::StringTokenizer::NextToken(bool trimmed)
{
int32_t start = mBufferPosition;
while (mBufferPosition < mBuffer.length())
{
++mBufferPosition;
if (IsDelimeter(mBuffer[mBufferPosition]))
{
++mBufferPosition;
break;
}
}
int32_t end = mBufferPosition;
// Retrieve the next section ending with a line break boundary
UnicodeString token = mBuffer.tempSubStringBetween(start, end);
// Discard any trailing whitespace if directed
if (trimmed)
{
token.trim();
}
return token;
}
示例2: Test
void IdnaConfTest::Test(void){
if (!ReadAndConvertFile())return;
UnicodeString s;
UnicodeString key;
UnicodeString value;
// skip everything before the first "=====" and "=====" itself
do {
if (!ReadOneLine(s)) {
errln("End of file prematurely found");
break;
}
}
while (s.compare(C_TAG, -1) != 0); //"====="
while(ReadOneLine(s)){
s.trim();
key.remove();
value.remove();
if (s.compare(C_TAG, -1) == 0){ //"====="
Call();
} else {
// explain key:value
int p = s.indexOf((UChar)0x3A); // :
key.setTo(s,0,p).trim();
value.setTo(s,p+1).trim();
if (key.compare(C_TYPE, -1) == 0){
if (value.compare(C_TOASCII, -1) == 0) {
type = 0;
} else if (value.compare(C_TOUNICODE, -1) == 0){
type = 1;
}
} else if (key.compare(C_PASSFAIL, -1) == 0){
if (value.compare(C_PASS, -1) == 0){
passfail = 0;
} else if (value.compare(C_FAIL, -1) == 0){
passfail = 1;
}
} else if (key.compare(C_DESC, -1) == 0){
if (value.indexOf(C_USESTD3ASCIIRULES, u_strlen(C_USESTD3ASCIIRULES), 0) == -1){
option = 1; // not found
} else {
option = 0;
}
id.setTo(value, 0, value.indexOf((UChar)0x20)); // space
} else if (key.compare(C_NAMEZONE, -1) == 0){
ExplainCodePointTag(value);
namezone.setTo(value);
} else if (key.compare(C_NAMEBASE, -1) == 0){
ExplainCodePointTag(value);
namebase.setTo(value);
}
// just skip other lines
}
}
Call(); // for last record
}
示例3: findKeyword
// -------------------------------------
// Finds the string, s, in the string array, list.
int32_t MessageFormat::findKeyword(const UnicodeString& s,
const UChar * const *list)
{
if (s.length() == 0)
return 0; // default
UnicodeString buffer = s;
// Trims the space characters and turns all characters
// in s to lower case.
buffer.trim().toLower("");
for (int32_t i = 0; list[i]; ++i) {
if (!buffer.compare(list[i], u_strlen(list[i]))) {
return i;
}
}
return -1;
}
示例4: withPerUnitAndAppend
int32_t MeasureFormat::withPerUnitAndAppend(
const UnicodeString &formatted,
const MeasureUnit &perUnit,
UnicodeString &appendTo,
UErrorCode &status) const {
int32_t offset = -1;
if (U_FAILURE(status)) {
return offset;
}
const SimpleFormatter *perUnitFormatter =
getFormatterOrNull(perUnit, width, MeasureFormatCacheData::PER_UNIT_INDEX);
if (perUnitFormatter != NULL) {
const UnicodeString *params[] = {&formatted};
perUnitFormatter->formatAndAppend(
params,
UPRV_LENGTHOF(params),
appendTo,
&offset,
1,
status);
return offset;
}
const SimpleFormatter *perFormatter = getPerFormatter(width, status);
const SimpleFormatter *pattern =
getPluralFormatter(perUnit, width, StandardPlural::ONE, status);
if (U_FAILURE(status)) {
return offset;
}
UnicodeString perUnitString = pattern->getTextWithNoArguments();
perUnitString.trim();
const UnicodeString *params[] = {&formatted, &perUnitString};
perFormatter->formatAndAppend(
params,
UPRV_LENGTHOF(params),
appendTo,
&offset,
1,
status);
return offset;
}
示例5: onlySpaces
static UBool onlySpaces(UnicodeString u) {
return u.trim().length() == 0;
}
示例6: while
void
ChoiceFormat::applyPattern(const UnicodeString& pattern,
UParseError& parseError,
UErrorCode& status)
{
if (U_FAILURE(status))
{
return;
}
// Clear error struct
parseError.offset = -1;
parseError.preContext[0] = parseError.postContext[0] = (UChar)0;
// Perform 2 passes. The first computes the number of limits in
// this pattern (fCount), which is 1 more than the number of
// literal VERTICAL_BAR characters.
int32_t count = 1;
int32_t i;
for (i=0; i<pattern.length(); ++i) {
UChar c = pattern[i];
if (c == SINGLE_QUOTE) {
// Skip over the entire quote, including embedded
// contiguous pairs of SINGLE_QUOTE.
for (;;) {
do {
++i;
} while (i<pattern.length() &&
pattern[i] != SINGLE_QUOTE);
if ((i+1)<pattern.length() &&
pattern[i+1] == SINGLE_QUOTE) {
// SINGLE_QUOTE pair; skip over it
++i;
} else {
break;
}
}
} else if (c == VERTICAL_BAR) {
++count;
}
}
// Allocate the required storage.
double *newLimits = (double*) uprv_malloc( sizeof(double) * count);
/* test for NULL */
if (newLimits == 0) {
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
UBool *newClosures = (UBool*) uprv_malloc( sizeof(UBool) * count);
/* test for NULL */
if (newClosures == 0) {
status = U_MEMORY_ALLOCATION_ERROR;
uprv_free(newLimits);
return;
}
UnicodeString *newFormats = new UnicodeString[count];
/* test for NULL */
if (newFormats == 0) {
status = U_MEMORY_ALLOCATION_ERROR;
uprv_free(newLimits);
uprv_free(newClosures);
return;
}
// Perform the second pass
int32_t k = 0; // index into newXxx[] arrays
UnicodeString buf; // scratch buffer
UBool inQuote = FALSE;
UBool inNumber = TRUE; // TRUE before < or #, FALSE after
for (i=0; i<pattern.length(); ++i) {
UChar c = pattern[i];
if (c == SINGLE_QUOTE) {
// Check for SINGLE_QUOTE pair indicating a literal quote
if ((i+1) < pattern.length() &&
pattern[i+1] == SINGLE_QUOTE) {
buf += SINGLE_QUOTE;
++i;
} else {
inQuote = !inQuote;
}
} else if (inQuote) {
buf += c;
} else if (c == LESS_THAN || c == LESS_EQUAL || c == LESS_EQUAL2) {
if (!inNumber || buf.length() == 0) {
goto error;
}
inNumber = FALSE;
double limit;
buf.trim();
if (!buf.compare(gPositiveInfinity, POSITIVE_INF_STRLEN)) {
limit = uprv_getInfinity();
} else if (!buf.compare(gNegativeInfinity, NEGATIVE_INF_STRLEN)) {
limit = -uprv_getInfinity();
} else {
limit = stod(buf);
}
//.........这里部分代码省略.........