int32_t destLength=src1Length+src2Length; if(destLength>destCapacity) { /* the merged sort key does not fit into the destination */ return destLength;
}
/* merge the sort keys with the same number of levels */
uint8_t *p=dest; for(;;) { /* copy level from src1 not including 00 or 01 */
uint8_t b; while((b=*src1)>=2) {
++src1;
*p++=b;
}
/* add a 02 merge separator */
*p++=2;
/* copy level from src2 not including 00 or 01 */ while((b=*src2)>=2) {
++src2;
*p++=b;
}
/* if both sort keys have another level, then add a 01 level separator and continue */ if(*src1==1 && *src2==1) {
++src1;
++src2;
*p++=1;
} else { break;
}
}
/* * here, at least one sort key is finished now, but the other one * might have some contents left from containing more levels; * that contents is just appended to the result
*/ if(*src1!=0) { /* src1 is not finished, therefore *src2==0, and src1 is appended */
src2=src1;
} /* append src2, "the other, unfinished sort key" */ while((*p++=*src2++)!=0) {}
/* the actual length might be less than destLength if either sort key contained illegally embedded zero bytes */ return (int32_t)(p-dest);
}
/** * Produce a bound for a given sortkey and a number of levels.
*/
U_CAPI int32_t U_EXPORT2
ucol_getBound(const uint8_t *source,
int32_t sourceLength,
UColBoundMode boundType,
uint32_t noOfLevels,
uint8_t *result,
int32_t resultLength,
UErrorCode *status)
{ // consistency checks if(status == nullptr || U_FAILURE(*status)) { return 0;
} if(source == nullptr) {
*status = U_ILLEGAL_ARGUMENT_ERROR; return 0;
}
int32_t sourceIndex = 0; // Scan the string until we skip enough of the key OR reach the end of the key do {
sourceIndex++; if(source[sourceIndex] == Collation::LEVEL_SEPARATOR_BYTE) {
noOfLevels--;
}
} while (noOfLevels > 0
&& (source[sourceIndex] != 0 || sourceIndex < sourceLength));
// READ ME: this code assumes that the values for boundType // enum will not changes. They are set so that the enum value // corresponds to the number of extra bytes each bound type // needs. if(result != nullptr && resultLength >= sourceIndex+boundType) {
uprv_memcpy(result, source, sourceIndex); switch(boundType) { // Lower bound just gets terminated. No extra bytes case UCOL_BOUND_LOWER: // = 0 break; // Upper bound needs one extra byte case UCOL_BOUND_UPPER: // = 1
result[sourceIndex++] = 2; break; // Upper long bound needs two extra bytes case UCOL_BOUND_UPPER_LONG: // = 2
result[sourceIndex++] = 0xFF;
result[sourceIndex++] = 0xFF; break; default:
*status = U_ILLEGAL_ARGUMENT_ERROR; return 0;
}
result[sourceIndex++] = 0;
U_CAPI void U_EXPORT2
ucol_getUCAVersion(const UCollator* coll, UVersionInfo info) { const Collator *c = Collator::fromUCollator(coll); if(c != nullptr) {
UVersionInfo v;
c->getVersion(v); // Note: This is tied to how the current implementation encodes the UCA version // in the overall getVersion(). // Alternatively, we could load the root collator and get at lower-level data from there. // Either way, it will reflect the input collator's UCA version only // if it is a known implementation. // It would be cleaner to make this a virtual Collator method.
info[0] = v[1] >> 3;
info[1] = v[1] & 7;
info[2] = v[2] >> 6;
info[3] = 0;
}
}
U_CAPI const char16_t * U_EXPORT2
ucol_getRules(const UCollator *coll, int32_t *length) { const RuleBasedCollator *rbc = RuleBasedCollator::rbcFromUCollator(coll); // OK to crash if coll==nullptr: We do not want to check "this" pointers. if(rbc != nullptr || coll == nullptr) { const UnicodeString &rules = rbc->getRules();
U_ASSERT(rules.getBuffer()[rules.length()] == 0);
*length = rules.length(); return rules.getBuffer();
} staticconst char16_t _NUL = 0;
*length = 0; return &_NUL;
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.12Bemerkung:
(vorverarbeitet am 2026-04-26)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.