ICU-845 implement Normalizer::concatenate
X-SVN-Rev: 7960
This commit is contained in:
parent
e7b91a2472
commit
a66e125f97
@ -165,6 +165,9 @@ Normalizer::normalize(const UnicodeString& source,
|
||||
UErrorCode &status) {
|
||||
if(source.isBogus() || U_FAILURE(status)) {
|
||||
result.setToBogus();
|
||||
if(U_SUCCESS(status)) {
|
||||
status=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
}
|
||||
} else {
|
||||
UChar *buffer=result.getBuffer(source.length());
|
||||
int32_t length=unorm_internalNormalize(buffer, result.getCapacity(),
|
||||
@ -207,6 +210,9 @@ Normalizer::compose(const UnicodeString& source,
|
||||
UErrorCode &status) {
|
||||
if(source.isBogus() || U_FAILURE(status)) {
|
||||
result.setToBogus();
|
||||
if(U_SUCCESS(status)) {
|
||||
status=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
}
|
||||
} else {
|
||||
UChar *buffer=result.getBuffer(source.length());
|
||||
int32_t length=unorm_compose(buffer, result.getCapacity(),
|
||||
@ -237,6 +243,9 @@ Normalizer::decompose(const UnicodeString& source,
|
||||
UErrorCode &status) {
|
||||
if(source.isBogus() || U_FAILURE(status)) {
|
||||
result.setToBogus();
|
||||
if(U_SUCCESS(status)) {
|
||||
status=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
}
|
||||
} else {
|
||||
UChar *buffer=result.getBuffer(source.length());
|
||||
int32_t length=unorm_decompose(buffer, result.getCapacity(),
|
||||
@ -260,6 +269,42 @@ Normalizer::decompose(const UnicodeString& source,
|
||||
}
|
||||
}
|
||||
|
||||
UnicodeString &
|
||||
Normalizer::concatenate(UnicodeString &left, UnicodeString &right,
|
||||
UnicodeString &result,
|
||||
UNormalizationMode mode, int32_t options,
|
||||
UErrorCode &errorCode) {
|
||||
if(left.isBogus() || right.isBogus() || U_FAILURE(errorCode)) {
|
||||
result.setToBogus();
|
||||
if(U_SUCCESS(errorCode)) {
|
||||
errorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
}
|
||||
} else {
|
||||
UChar *buffer=result.getBuffer(left.length()+right.length());
|
||||
int32_t length=unorm_concatenate(left.getBuffer(), left.length(),
|
||||
right.getBuffer(), right.length(),
|
||||
buffer, result.getCapacity(),
|
||||
mode, options,
|
||||
&errorCode);
|
||||
result.releaseBuffer(length);
|
||||
if(errorCode==U_BUFFER_OVERFLOW_ERROR) {
|
||||
errorCode=U_ZERO_ERROR;
|
||||
buffer=result.getBuffer(length);
|
||||
int32_t length=unorm_concatenate(left.getBuffer(), left.length(),
|
||||
right.getBuffer(), right.length(),
|
||||
buffer, result.getCapacity(),
|
||||
mode, options,
|
||||
&errorCode);
|
||||
result.releaseBuffer(length);
|
||||
}
|
||||
|
||||
if(U_FAILURE(errorCode)) {
|
||||
result.setToBogus();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Iteration API
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -272,6 +272,41 @@ public:
|
||||
static UNormalizationCheckResult
|
||||
quickCheck(const UnicodeString &source, UNormalizationMode mode, UErrorCode &status);
|
||||
|
||||
/*
|
||||
* Concatenate normalized strings, making sure that the result is normalized as well.
|
||||
*
|
||||
* If both the left and the right strings are in
|
||||
* the normalization form according to "mode",
|
||||
* then the result will be
|
||||
*
|
||||
* \code
|
||||
* dest=normalize(left+right, mode)
|
||||
* \endcode
|
||||
*
|
||||
* For details see unorm_concatenate in unorm.h.
|
||||
*
|
||||
* @param left Left source string.
|
||||
* @param right Right source string.
|
||||
* @param dest The output string.
|
||||
* @param mode The normalization mode.
|
||||
* @param options A bit set of normalization options.
|
||||
* @param pErrorCode ICU error code in/out parameter.
|
||||
* Must fulfill U_SUCCESS before the function call.
|
||||
* @return result
|
||||
*
|
||||
* @see unorm_concatenate
|
||||
* @see normalize
|
||||
* @see unorm_next
|
||||
* @see unorm_previous
|
||||
*
|
||||
* @draft ICU 2.1
|
||||
*/
|
||||
static UnicodeString &
|
||||
concatenate(UnicodeString &left, UnicodeString &right,
|
||||
UnicodeString &result,
|
||||
UNormalizationMode mode, int32_t options,
|
||||
UErrorCode &errorCode);
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Iteration API
|
||||
//-------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user