- if(source.isBogus() || U_FAILURE(status)) {
- result.setToBogus();
- if(U_SUCCESS(status)) {
- status=U_ILLEGAL_ARGUMENT_ERROR;
- }
- } else {
- UnicodeString localDest;
- UnicodeString *dest;
-
- if(&source!=&result) {
- dest=&result;
- } else {
- // the source and result strings are the same object, use a temporary one
- dest=&localDest;
- }
-
- UChar *buffer=dest->getBuffer(source.length());
- int32_t length=unorm_compose(buffer, dest->getCapacity(),
- source.getBuffer(), source.length(),
- compat, options,
- &status);
- dest->releaseBuffer(U_SUCCESS(status) ? length : 0);
- if(status==U_BUFFER_OVERFLOW_ERROR) {
- status=U_ZERO_ERROR;
- buffer=dest->getBuffer(length);
- length=unorm_compose(buffer, dest->getCapacity(),
- source.getBuffer(), source.length(),
- compat, options,
- &status);
- dest->releaseBuffer(U_SUCCESS(status) ? length : 0);
- }
-
- if(dest==&localDest) {
- result=*dest;
- }
- if(U_FAILURE(status)) {
- result.setToBogus();
- }
- }
+ normalize(source, compat ? UNORM_NFKC : UNORM_NFC, options, result, status);