mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-10 15:42:14 +00:00
ICU-21833 Replace UChar with char16_t in C++ code.
This commit is contained in:
parent
2de88f9d9c
commit
9fd2742dfa
3 changed files with 51 additions and 51 deletions
|
@ -103,14 +103,14 @@ class U_COMMON_API UCharsDictionaryMatcher : public DictionaryMatcher {
|
|||
public:
|
||||
// constructs a new UCharsDictionaryMatcher.
|
||||
// The UDataMemory * will be closed on this object's destruction.
|
||||
UCharsDictionaryMatcher(const UChar *c, UDataMemory *f) : characters(c), file(f) { }
|
||||
UCharsDictionaryMatcher(const char16_t *c, UDataMemory *f) : characters(c), file(f) { }
|
||||
virtual ~UCharsDictionaryMatcher();
|
||||
virtual int32_t matches(UText *text, int32_t maxLength, int32_t limit,
|
||||
int32_t *lengths, int32_t *cpLengths, int32_t *values,
|
||||
int32_t *prefix) const override;
|
||||
virtual int32_t getType() const override;
|
||||
private:
|
||||
const UChar *characters;
|
||||
const char16_t *characters;
|
||||
UDataMemory *file;
|
||||
};
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
*/
|
||||
virtual ~LSTMBreakEngine();
|
||||
|
||||
virtual const UChar* name() const;
|
||||
virtual const char16_t* name() const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
@ -79,7 +79,7 @@ U_CAPI const LSTMData* U_EXPORT2 CreateLSTMDataForScript(
|
|||
UScriptCode script, UErrorCode& status);
|
||||
|
||||
U_CAPI void U_EXPORT2 DeleteLSTMData(const LSTMData* data);
|
||||
U_CAPI const UChar* U_EXPORT2 LSTMDataName(const LSTMData* data);
|
||||
U_CAPI const char16_t* U_EXPORT2 LSTMDataName(const LSTMData* data);
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
|
|
|
@ -99,16 +99,16 @@ public:
|
|||
* Decomposes c, which must be a Hangul syllable, into buffer
|
||||
* and returns the length of the decomposition (2 or 3).
|
||||
*/
|
||||
static inline int32_t decompose(UChar32 c, UChar buffer[3]) {
|
||||
static inline int32_t decompose(UChar32 c, char16_t buffer[3]) {
|
||||
c-=HANGUL_BASE;
|
||||
UChar32 c2=c%JAMO_T_COUNT;
|
||||
c/=JAMO_T_COUNT;
|
||||
buffer[0]=(UChar)(JAMO_L_BASE+c/JAMO_V_COUNT);
|
||||
buffer[1]=(UChar)(JAMO_V_BASE+c%JAMO_V_COUNT);
|
||||
buffer[0]=(char16_t)(JAMO_L_BASE+c/JAMO_V_COUNT);
|
||||
buffer[1]=(char16_t)(JAMO_V_BASE+c%JAMO_V_COUNT);
|
||||
if(c2==0) {
|
||||
return 2;
|
||||
} else {
|
||||
buffer[2]=(UChar)(JAMO_T_BASE+c2);
|
||||
buffer[2]=(char16_t)(JAMO_T_BASE+c2);
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
@ -117,17 +117,17 @@ public:
|
|||
* Decomposes c, which must be a Hangul syllable, into buffer.
|
||||
* This is the raw, not recursive, decomposition. Its length is always 2.
|
||||
*/
|
||||
static inline void getRawDecomposition(UChar32 c, UChar buffer[2]) {
|
||||
static inline void getRawDecomposition(UChar32 c, char16_t buffer[2]) {
|
||||
UChar32 orig=c;
|
||||
c-=HANGUL_BASE;
|
||||
UChar32 c2=c%JAMO_T_COUNT;
|
||||
if(c2==0) {
|
||||
c/=JAMO_T_COUNT;
|
||||
buffer[0]=(UChar)(JAMO_L_BASE+c/JAMO_V_COUNT);
|
||||
buffer[1]=(UChar)(JAMO_V_BASE+c%JAMO_V_COUNT);
|
||||
buffer[0]=(char16_t)(JAMO_L_BASE+c/JAMO_V_COUNT);
|
||||
buffer[1]=(char16_t)(JAMO_V_BASE+c%JAMO_V_COUNT);
|
||||
} else {
|
||||
buffer[0]=(UChar)(orig-c2); // LV syllable
|
||||
buffer[1]=(UChar)(JAMO_T_BASE+c2);
|
||||
buffer[0]=(char16_t)(orig-c2); // LV syllable
|
||||
buffer[1]=(char16_t)(JAMO_T_BASE+c2);
|
||||
}
|
||||
}
|
||||
private:
|
||||
|
@ -154,22 +154,22 @@ public:
|
|||
|
||||
UBool isEmpty() const { return start==limit; }
|
||||
int32_t length() const { return (int32_t)(limit-start); }
|
||||
UChar *getStart() { return start; }
|
||||
UChar *getLimit() { return limit; }
|
||||
char16_t *getStart() { return start; }
|
||||
char16_t *getLimit() { return limit; }
|
||||
uint8_t getLastCC() const { return lastCC; }
|
||||
|
||||
UBool equals(const UChar *start, const UChar *limit) const;
|
||||
UBool equals(const char16_t *start, const char16_t *limit) const;
|
||||
UBool equals(const uint8_t *otherStart, const uint8_t *otherLimit) const;
|
||||
|
||||
UBool append(UChar32 c, uint8_t cc, UErrorCode &errorCode) {
|
||||
return (c<=0xffff) ?
|
||||
appendBMP((UChar)c, cc, errorCode) :
|
||||
appendBMP((char16_t)c, cc, errorCode) :
|
||||
appendSupplementary(c, cc, errorCode);
|
||||
}
|
||||
UBool append(const UChar *s, int32_t length, UBool isNFD,
|
||||
UBool append(const char16_t *s, int32_t length, UBool isNFD,
|
||||
uint8_t leadCC, uint8_t trailCC,
|
||||
UErrorCode &errorCode);
|
||||
UBool appendBMP(UChar c, uint8_t cc, UErrorCode &errorCode) {
|
||||
UBool appendBMP(char16_t c, uint8_t cc, UErrorCode &errorCode) {
|
||||
if(remainingCapacity==0 && !resize(1, errorCode)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -186,10 +186,10 @@ public:
|
|||
return true;
|
||||
}
|
||||
UBool appendZeroCC(UChar32 c, UErrorCode &errorCode);
|
||||
UBool appendZeroCC(const UChar *s, const UChar *sLimit, UErrorCode &errorCode);
|
||||
UBool appendZeroCC(const char16_t *s, const char16_t *sLimit, UErrorCode &errorCode);
|
||||
void remove();
|
||||
void removeSuffix(int32_t suffixLength);
|
||||
void setReorderingLimit(UChar *newLimit) {
|
||||
void setReorderingLimit(char16_t *newLimit) {
|
||||
remainingCapacity+=(int32_t)(limit-newLimit);
|
||||
reorderStart=limit=newLimit;
|
||||
lastCC=0;
|
||||
|
@ -213,9 +213,9 @@ private:
|
|||
|
||||
UBool appendSupplementary(UChar32 c, uint8_t cc, UErrorCode &errorCode);
|
||||
void insert(UChar32 c, uint8_t cc);
|
||||
static void writeCodePoint(UChar *p, UChar32 c) {
|
||||
static void writeCodePoint(char16_t *p, UChar32 c) {
|
||||
if(c<=0xffff) {
|
||||
*p=(UChar)c;
|
||||
*p=(char16_t)c;
|
||||
} else {
|
||||
p[0]=U16_LEAD(c);
|
||||
p[1]=U16_TRAIL(c);
|
||||
|
@ -225,7 +225,7 @@ private:
|
|||
|
||||
const Normalizer2Impl &impl;
|
||||
UnicodeString &str;
|
||||
UChar *start, *reorderStart, *limit;
|
||||
char16_t *start, *reorderStart, *limit;
|
||||
int32_t remainingCapacity;
|
||||
uint8_t lastCC;
|
||||
|
||||
|
@ -234,7 +234,7 @@ private:
|
|||
void skipPrevious(); // Requires start<codePointStart.
|
||||
uint8_t previousCC(); // Returns 0 if there is no previous character.
|
||||
|
||||
UChar *codePointStart, *codePointLimit;
|
||||
char16_t *codePointStart, *codePointLimit;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -322,12 +322,12 @@ public:
|
|||
* @param limit The end of the string, or NULL.
|
||||
* @return The lccc(c) in bits 15..8 and tccc(c) in bits 7..0.
|
||||
*/
|
||||
uint16_t nextFCD16(const UChar *&s, const UChar *limit) const {
|
||||
uint16_t nextFCD16(const char16_t *&s, const char16_t *limit) const {
|
||||
UChar32 c=*s++;
|
||||
if(c<minDecompNoCP || !singleLeadMightHaveNonZeroFCD16(c)) {
|
||||
return 0;
|
||||
}
|
||||
UChar c2;
|
||||
char16_t c2;
|
||||
if(U16_IS_LEAD(c) && s!=limit && U16_IS_TRAIL(c2=*s)) {
|
||||
c=U16_GET_SUPPLEMENTARY(c, c2);
|
||||
++s;
|
||||
|
@ -340,7 +340,7 @@ public:
|
|||
* @param s A valid pointer into a string. Requires start<s.
|
||||
* @return The lccc(c) in bits 15..8 and tccc(c) in bits 7..0.
|
||||
*/
|
||||
uint16_t previousFCD16(const UChar *start, const UChar *&s) const {
|
||||
uint16_t previousFCD16(const char16_t *start, const char16_t *&s) const {
|
||||
UChar32 c=*--s;
|
||||
if(c<minDecompNoCP) {
|
||||
return 0;
|
||||
|
@ -350,7 +350,7 @@ public:
|
|||
return 0;
|
||||
}
|
||||
} else {
|
||||
UChar c2;
|
||||
char16_t c2;
|
||||
if(start<s && U16_IS_LEAD(c2=*(s-1))) {
|
||||
c=U16_GET_SUPPLEMENTARY(c2, c);
|
||||
--s;
|
||||
|
@ -376,7 +376,7 @@ public:
|
|||
* @param length out-only, takes the length of the decomposition, if any
|
||||
* @return pointer to the decomposition, or NULL if none
|
||||
*/
|
||||
const UChar *getDecomposition(UChar32 c, UChar buffer[4], int32_t &length) const;
|
||||
const char16_t *getDecomposition(UChar32 c, char16_t buffer[4], int32_t &length) const;
|
||||
|
||||
/**
|
||||
* Gets the raw decomposition for one code point.
|
||||
|
@ -385,7 +385,7 @@ public:
|
|||
* @param length out-only, takes the length of the decomposition, if any
|
||||
* @return pointer to the decomposition, or NULL if none
|
||||
*/
|
||||
const UChar *getRawDecomposition(UChar32 c, UChar buffer[30], int32_t &length) const;
|
||||
const char16_t *getRawDecomposition(UChar32 c, char16_t buffer[30], int32_t &length) const;
|
||||
|
||||
UChar32 composePair(UChar32 a, UChar32 b) const;
|
||||
|
||||
|
@ -480,13 +480,13 @@ public:
|
|||
* limit can be NULL if src is NUL-terminated.
|
||||
* destLengthEstimate is the initial dest buffer capacity and can be -1.
|
||||
*/
|
||||
void decompose(const UChar *src, const UChar *limit,
|
||||
void decompose(const char16_t *src, const char16_t *limit,
|
||||
UnicodeString &dest, int32_t destLengthEstimate,
|
||||
UErrorCode &errorCode) const;
|
||||
|
||||
const UChar *decompose(const UChar *src, const UChar *limit,
|
||||
const char16_t *decompose(const char16_t *src, const char16_t *limit,
|
||||
ReorderingBuffer *buffer, UErrorCode &errorCode) const;
|
||||
void decomposeAndAppend(const UChar *src, const UChar *limit,
|
||||
void decomposeAndAppend(const char16_t *src, const char16_t *limit,
|
||||
UBool doDecompose,
|
||||
UnicodeString &safeMiddle,
|
||||
ReorderingBuffer &buffer,
|
||||
|
@ -497,15 +497,15 @@ public:
|
|||
const uint8_t *src, const uint8_t *limit,
|
||||
ByteSink *sink, Edits *edits, UErrorCode &errorCode) const;
|
||||
|
||||
UBool compose(const UChar *src, const UChar *limit,
|
||||
UBool compose(const char16_t *src, const char16_t *limit,
|
||||
UBool onlyContiguous,
|
||||
UBool doCompose,
|
||||
ReorderingBuffer &buffer,
|
||||
UErrorCode &errorCode) const;
|
||||
const UChar *composeQuickCheck(const UChar *src, const UChar *limit,
|
||||
const char16_t *composeQuickCheck(const char16_t *src, const char16_t *limit,
|
||||
UBool onlyContiguous,
|
||||
UNormalizationCheckResult *pQCResult) const;
|
||||
void composeAndAppend(const UChar *src, const UChar *limit,
|
||||
void composeAndAppend(const char16_t *src, const char16_t *limit,
|
||||
UBool doCompose,
|
||||
UBool onlyContiguous,
|
||||
UnicodeString &safeMiddle,
|
||||
|
@ -517,9 +517,9 @@ public:
|
|||
const uint8_t *src, const uint8_t *limit,
|
||||
ByteSink *sink, icu::Edits *edits, UErrorCode &errorCode) const;
|
||||
|
||||
const UChar *makeFCD(const UChar *src, const UChar *limit,
|
||||
const char16_t *makeFCD(const char16_t *src, const char16_t *limit,
|
||||
ReorderingBuffer *buffer, UErrorCode &errorCode) const;
|
||||
void makeFCDAndAppend(const UChar *src, const UChar *limit,
|
||||
void makeFCDAndAppend(const char16_t *src, const char16_t *limit,
|
||||
UBool doMakeFCD,
|
||||
UnicodeString &safeMiddle,
|
||||
ReorderingBuffer &buffer,
|
||||
|
@ -608,7 +608,7 @@ private:
|
|||
return (uint8_t)(*getMapping(norm16)>>8); // tccc from yesNo
|
||||
}
|
||||
}
|
||||
uint8_t getPreviousTrailCC(const UChar *start, const UChar *p) const;
|
||||
uint8_t getPreviousTrailCC(const char16_t *start, const char16_t *p) const;
|
||||
uint8_t getPreviousTrailCC(const uint8_t *start, const uint8_t *p) const;
|
||||
|
||||
// Requires algorithmic-NoNo.
|
||||
|
@ -651,14 +651,14 @@ private:
|
|||
getCompositionsListForComposite(norm16);
|
||||
}
|
||||
|
||||
const UChar *copyLowPrefixFromNulTerminated(const UChar *src,
|
||||
const char16_t *copyLowPrefixFromNulTerminated(const char16_t *src,
|
||||
UChar32 minNeedDataCP,
|
||||
ReorderingBuffer *buffer,
|
||||
UErrorCode &errorCode) const;
|
||||
|
||||
enum StopAt { STOP_AT_LIMIT, STOP_AT_DECOMP_BOUNDARY, STOP_AT_COMP_BOUNDARY };
|
||||
|
||||
const UChar *decomposeShort(const UChar *src, const UChar *limit,
|
||||
const char16_t *decomposeShort(const char16_t *src, const char16_t *limit,
|
||||
UBool stopAtCompBoundary, UBool onlyContiguous,
|
||||
ReorderingBuffer &buffer, UErrorCode &errorCode) const;
|
||||
UBool decompose(UChar32 c, uint16_t norm16,
|
||||
|
@ -679,9 +679,9 @@ private:
|
|||
UBool norm16HasCompBoundaryBefore(uint16_t norm16) const {
|
||||
return norm16 < minNoNoCompNoMaybeCC || isAlgorithmicNoNo(norm16);
|
||||
}
|
||||
UBool hasCompBoundaryBefore(const UChar *src, const UChar *limit) const;
|
||||
UBool hasCompBoundaryBefore(const char16_t *src, const char16_t *limit) const;
|
||||
UBool hasCompBoundaryBefore(const uint8_t *src, const uint8_t *limit) const;
|
||||
UBool hasCompBoundaryAfter(const UChar *start, const UChar *p,
|
||||
UBool hasCompBoundaryAfter(const char16_t *start, const char16_t *p,
|
||||
UBool onlyContiguous) const;
|
||||
UBool hasCompBoundaryAfter(const uint8_t *start, const uint8_t *p,
|
||||
UBool onlyContiguous) const;
|
||||
|
@ -695,11 +695,11 @@ private:
|
|||
(norm16 & DELTA_TCCC_MASK) <= DELTA_TCCC_1 : *getMapping(norm16) <= 0x1ff);
|
||||
}
|
||||
|
||||
const UChar *findPreviousCompBoundary(const UChar *start, const UChar *p, UBool onlyContiguous) const;
|
||||
const UChar *findNextCompBoundary(const UChar *p, const UChar *limit, UBool onlyContiguous) const;
|
||||
const char16_t *findPreviousCompBoundary(const char16_t *start, const char16_t *p, UBool onlyContiguous) const;
|
||||
const char16_t *findNextCompBoundary(const char16_t *p, const char16_t *limit, UBool onlyContiguous) const;
|
||||
|
||||
const UChar *findPreviousFCDBoundary(const UChar *start, const UChar *p) const;
|
||||
const UChar *findNextFCDBoundary(const UChar *p, const UChar *limit) const;
|
||||
const char16_t *findPreviousFCDBoundary(const char16_t *start, const char16_t *p) const;
|
||||
const char16_t *findNextFCDBoundary(const char16_t *p, const char16_t *limit) const;
|
||||
|
||||
void makeCanonIterDataFromNorm16(UChar32 start, UChar32 end, const uint16_t norm16,
|
||||
CanonIterData &newData, UErrorCode &errorCode) const;
|
||||
|
@ -710,9 +710,9 @@ private:
|
|||
// UVersionInfo dataVersion;
|
||||
|
||||
// BMP code point thresholds for quick check loops looking at single UTF-16 code units.
|
||||
UChar minDecompNoCP;
|
||||
UChar minCompNoMaybeCP;
|
||||
UChar minLcccCP;
|
||||
char16_t minDecompNoCP;
|
||||
char16_t minCompNoMaybeCP;
|
||||
char16_t minLcccCP;
|
||||
|
||||
// Norm16 value thresholds for quick check combinations and types of extra data.
|
||||
uint16_t minYesNo;
|
||||
|
|
Loading…
Add table
Reference in a new issue