本文整理汇总了C++中UnicodeString::append方法的典型用法代码示例。如果您正苦于以下问题:C++ UnicodeString::append方法的具体用法?C++ UnicodeString::append怎么用?C++ UnicodeString::append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnicodeString
的用法示例。
在下文中一共展示了UnicodeString::append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: appendRange
static void appendRange(
const UnicodeString &src,
int32_t start,
int32_t end,
UnicodeString &dest) {
dest.append(src, start, end - start);
}
示例2: ExplainCodePointTag
/* Explain <xxxxx> tag to a native value
*
* Since <xxxxx> is always larger than the native value,
* the operation will replace the tag directly in the buffer,
* and, of course, will shift tail elements.
*/
void IdnaConfTest::ExplainCodePointTag(UnicodeString& buf){
buf.append((UChar)0); // add a terminal NULL
UChar* bufBase = buf.getBuffer(buf.length());
UChar* p = bufBase;
while (*p != 0){
if ( *p != 0x3C){ // <
*bufBase++ = *p++;
} else {
p++; // skip <
UChar32 cp = 0;
for ( ;*p != 0x3E; p++){ // >
if (0x30 <= *p && *p <= 0x39){ // 0-9
cp = (cp * 16) + (*p - 0x30);
} else if (0x61 <= *p && *p <= 0x66){ // a-f
cp = (cp * 16) + (*p - 0x61) + 10;
} else if (0x41 <= *p && *p <= 0x46) {// A-F
cp = (cp * 16) + (*p - 0x41) + 10;
}
// no else. hope everything is good.
}
p++; // skip >
if (U_IS_BMP(cp)){
*bufBase++ = cp;
} else {
*bufBase++ = U16_LEAD(cp);
*bufBase++ = U16_TRAIL(cp);
}
}
}
*bufBase = 0; // close our buffer
buf.releaseBuffer();
}
示例3: UnicodeString
static int32_t
_concatenate(const UChar *left, int32_t leftLength,
const UChar *right, int32_t rightLength,
UChar *dest, int32_t destCapacity,
const Normalizer2 *n2,
UErrorCode *pErrorCode) {
if(U_FAILURE(*pErrorCode)) {
return 0;
}
if(destCapacity<0 || (dest==NULL && destCapacity>0) ||
left==NULL || leftLength<-1 || right==NULL || rightLength<-1) {
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
/* check for overlapping right and destination */
if( dest!=NULL &&
((right>=dest && right<(dest+destCapacity)) ||
(rightLength>0 && dest>=right && dest<(right+rightLength)))
) {
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
/* allow left==dest */
UnicodeString destString;
if(left==dest) {
destString.setTo(dest, leftLength, destCapacity);
} else {
destString.setTo(dest, 0, destCapacity);
destString.append(left, leftLength);
}
return n2->append(destString, UnicodeString(rightLength<0, right, rightLength), *pErrorCode).
extract(dest, destCapacity, *pErrorCode);
}
示例4: doubleToStr
static void doubleToStr(
const void *doublePtr, UnicodeString &appendTo) {
char buffer[256];
double x = *static_cast<const double *>(doublePtr);
sprintf(buffer, "%f", x);
appendTo.append(buffer);
}
示例5: format
UnicodeString& GLUE_SYM (DateFormat ) :: format( Calendar& cal, UnicodeString& appendTo, FieldPosition& pos) const
{
#if DATE_FE_DEBUG
fprintf(stderr, "VCF " ICUGLUE_VER_STR " - formatting. \n");
#endif
int32_t len = appendTo.length();
UChar junk[200];
UErrorCode status = U_ZERO_ERROR;
UFieldPosition pos2;
int32_t nlen = OICU_udat_format(_this,
cal.getTime(status),
junk,
200,
&pos2,
&status);
// todo: use pos2
pos.setBeginIndex(len);
pos.setEndIndex(len += nlen);
appendTo.append(junk, nlen);
return appendTo;
}
示例6: UnicodeString
void
DateIntervalFormat::concatSingleDate2TimeInterval(const UChar* format,
int32_t formatLen,
const UnicodeString& datePattern,
UCalendarDateFields field,
UErrorCode& status) {
// following should not set wrong status
int32_t itvPtnIndex = DateIntervalInfo::calendarFieldToIntervalIndex(field,
status);
if ( U_FAILURE(status) ) {
return;
}
PatternInfo& timeItvPtnInfo = fIntervalPatterns[itvPtnIndex];
if ( !timeItvPtnInfo.firstPart.isEmpty() ) {
// UnicodeString allocated here is adopted, so no need to delete
UnicodeString* timeIntervalPattern = new UnicodeString(timeItvPtnInfo.firstPart);
timeIntervalPattern->append(timeItvPtnInfo.secondPart);
UnicodeString* dateStr = new UnicodeString(datePattern);
Formattable fmtArray[2];
fmtArray[0].adoptString(timeIntervalPattern);
fmtArray[1].adoptString(dateStr);
UnicodeString combinedPattern;
MessageFormat::format(UnicodeString(TRUE, format, formatLen),
fmtArray, 2, combinedPattern, status);
if ( U_FAILURE(status) ) {
return;
}
setIntervalPattern(field, combinedPattern, timeItvPtnInfo.laterDateFirst);
}
// else: fall back
// it should not happen if the interval format defined is valid
}
示例7: lock
ssize_t
BLocale::FormatDateTime(char* target, size_t maxSize, time_t time,
BDateFormatStyle dateStyle, BTimeFormatStyle timeStyle) const
{
BAutolock lock(fLock);
if (!lock.IsLocked())
return B_ERROR;
BString format;
fConventions.GetDateFormat(dateStyle, format);
ObjectDeleter<DateFormat> dateFormatter(_CreateDateFormatter(format));
if (dateFormatter.Get() == NULL)
return B_NO_MEMORY;
fConventions.GetTimeFormat(timeStyle, format);
ObjectDeleter<DateFormat> timeFormatter(_CreateTimeFormatter(format));
if (timeFormatter.Get() == NULL)
return B_NO_MEMORY;
UnicodeString icuString;
dateFormatter->format((UDate)time * 1000, icuString);
icuString.append(UnicodeString::fromUTF8(", "));
timeFormatter->format((UDate)time * 1000, icuString);
CheckedArrayByteSink stringConverter(target, maxSize);
icuString.toUTF8(stringConverter);
if (stringConverter.Overflowed())
return B_BAD_VALUE;
return stringConverter.NumberOfBytesWritten();
}
示例8: UnicodeString
U_CAPI int32_t U_EXPORT2
unorm_concatenate(const UChar * left, int32_t leftLength,
const UChar * right, int32_t rightLength,
UChar * dest, int32_t destCapacity,
UNormalizationMode mode, int32_t options,
UErrorCode * pErrorCode)
{
const Normalizer2 * n2 = Normalizer2Factory::getInstance(mode, *pErrorCode);
const UnicodeSet * uni32;
if (options & UNORM_UNICODE_3_2)
{
uni32 = uniset_getUnicode32Instance(*pErrorCode);
}
else
{
uni32 = NULL; // unused
}
FilteredNormalizer2 fn2(*n2, *uni32);
if (options & UNORM_UNICODE_3_2)
{
n2 = &fn2;
}
if (U_FAILURE(*pErrorCode))
{
return 0;
}
if (destCapacity < 0 || (dest == NULL && destCapacity > 0) ||
left == NULL || leftLength < -1 ||
right == NULL || rightLength < -1
)
{
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
/* check for overlapping right and destination */
if (dest != NULL &&
((right >= dest && right < (dest + destCapacity)) ||
(rightLength > 0 && dest >= right && dest < (right + rightLength)))
)
{
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
/* allow left==dest */
UnicodeString destString;
if (left == dest)
{
destString.setTo(dest, leftLength, destCapacity);
}
else
{
destString.setTo(dest, 0, destCapacity);
destString.append(left, leftLength);
}
return n2->append(destString, UnicodeString(rightLength < 0, right, rightLength), *pErrorCode).
extract(dest, destCapacity, *pErrorCode);
}
示例9: ceList
UnicodeString &StringSetMonkey::generateAlternative(const UnicodeString &testCase, UnicodeString &alternate)
{
// find out shortest string for the longest sequence of ces.
// needs to be refined to use dynamic programming, but will be roughly right
UErrorCode status = U_ZERO_ERROR;
CEList ceList(coll, testCase, status);
UnicodeString alt;
int32_t offset = 0;
if (ceList.size() == 0) {
return alternate.append(testCase);
}
while (offset < ceList.size()) {
int32_t ce = ceList.get(offset);
const StringList *strings = collData->getStringList(ce);
if (strings == NULL) {
return alternate.append(testCase);
}
int32_t stringCount = strings->size();
int32_t tries = 0;
// find random string that generates the same CEList
const CEList *ceList2 = NULL;
const UnicodeString *string = NULL;
UBool matches = FALSE;
do {
int32_t s = m_rand() % stringCount;
if (tries++ > stringCount) {
alternate.append(testCase);
return alternate;
}
string = strings->get(s);
ceList2 = collData->getCEList(string);
matches = ceList.matchesAt(offset, ceList2);
if (! matches) {
collData->freeCEList((CEList *) ceList2);
}
} while (! matches);
alt.append(*string);
offset += ceList2->size();
collData->freeCEList(ceList2);
}
const CEList altCEs(coll, alt, status);
if (ceList.matchesAt(0, &altCEs)) {
return alternate.append(alt);
}
return alternate.append(testCase);
}
示例10: STVtoID
/**
* Given source, target, and variant strings, concatenate them into a
* full ID. If the source is empty, then "Any" will be used for the
* source, so the ID will always be of the form s-t/v or s-t.
*/
void TransliteratorIDParser::STVtoID(const UnicodeString& source,
const UnicodeString& target,
const UnicodeString& variant,
UnicodeString& id) {
id = source;
if (id.length() == 0) {
id.setTo(ANY, 3);
}
id.append(TARGET_SEP).append(target);
if (variant.length() != 0) {
id.append(VARIANT_SEP).append(variant);
}
// NUL-terminate the ID string for getTerminatedBuffer.
// This prevents valgrind and Purify warnings.
id.append((UChar)0);
id.truncate(id.length()-1);
}
示例11:
void
UCharsTrieElement::setTo(const UnicodeString &s, int32_t val,
UnicodeString &strings, UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) {
return;
}
int32_t length=s.length();
if(length>0xffff) {
// Too long: We store the length in 1 unit.
errorCode=U_INDEX_OUTOFBOUNDS_ERROR;
return;
}
stringOffset=strings.length();
strings.append((UChar)length);
value=val;
strings.append(s);
}
示例12: 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;
}
示例13: separated
UnicodeString AlphabeticIndex::separated(const UnicodeString &item) {
UnicodeString result;
if (item.length() == 0) {
return result;
}
int32_t i = 0;
for (;;) {
UChar32 cp = item.char32At(i);
result.append(cp);
i = item.moveIndex32(i, 1);
if (i >= item.length()) {
break;
}
result.append(CGJ);
}
return result;
}
示例14: logln
// use these for now
void
ICUServiceTest::confirmStringsEqual(const UnicodeString& message, const UnicodeString& lhs, const UnicodeString& rhs)
{
UBool equ = lhs == rhs;
UnicodeString temp = message;
temp.append(" lhs: ");
temp.append(lhs);
temp.append(" rhs: ");
temp.append(rhs);
if (equ) {
logln(temp);
} else {
dataerrln(temp);
}
}
示例15: ruleSets
RuleBasedNumberFormat::RuleBasedNumberFormat(URBNFRuleSetTag tag, const Locale& alocale, UErrorCode& status)
: ruleSets(NULL)
, ruleSetDescriptions(NULL)
, numRuleSets(0)
, defaultRuleSet(NULL)
, locale(alocale)
, collator(NULL)
, decimalFormatSymbols(NULL)
, lenient(FALSE)
, lenientParseRules(NULL)
, localizations(NULL)
{
if (U_FAILURE(status)) {
return;
}
const char* rules_tag = "RBNFRules";
const char* fmt_tag = "";
switch (tag) {
case URBNF_SPELLOUT: fmt_tag = "SpelloutRules"; break;
case URBNF_ORDINAL: fmt_tag = "OrdinalRules"; break;
case URBNF_DURATION: fmt_tag = "DurationRules"; break;
case URBNF_NUMBERING_SYSTEM: fmt_tag = "NumberingSystemRules"; break;
default: status = U_ILLEGAL_ARGUMENT_ERROR; return;
}
// TODO: read localization info from resource
LocalizationInfo* locinfo = NULL;
UResourceBundle* nfrb = ures_open(U_ICUDATA_RBNF, locale.getName(), &status);
if (U_SUCCESS(status)) {
setLocaleIDs(ures_getLocaleByType(nfrb, ULOC_VALID_LOCALE, &status),
ures_getLocaleByType(nfrb, ULOC_ACTUAL_LOCALE, &status));
UResourceBundle* rbnfRules = ures_getByKeyWithFallback(nfrb, rules_tag, NULL, &status);
if (U_FAILURE(status)) {
ures_close(nfrb);
}
UResourceBundle* ruleSets = ures_getByKeyWithFallback(rbnfRules, fmt_tag, NULL, &status);
if (U_FAILURE(status)) {
ures_close(rbnfRules);
ures_close(nfrb);
return;
}
UnicodeString desc;
while (ures_hasNext(ruleSets)) {
desc.append(ures_getNextUnicodeString(ruleSets,NULL,&status));
}
UParseError perror;
init (desc, locinfo, perror, status);
ures_close(ruleSets);
ures_close(rbnfRules);
}
ures_close(nfrb);
}