ICU-1007 new NF*C implementation

X-SVN-Rev: 5119
This commit is contained in:
Markus Scherer 2001-06-28 00:34:35 +00:00
parent bd05b67248
commit b581e87e12
3 changed files with 1112 additions and 114 deletions

View File

@ -159,6 +159,26 @@ Normalizer::normalize(const UnicodeString& source,
return;
}
/* ### TODO: begin new implementation */
if(unorm_usesNewImplementation()) {
if(source.isBogus()) {
result.setToBogus();
} else {
/* make sure that we do not operate on the same buffer in source and result */
result.cloneArrayIfNeeded(-1, source.length()+20, FALSE);
result.fLength=unorm_internalNormalize(result.fArray, result.fCapacity,
source.fArray, source.fLength,
getUNormalizationMode(mode, status), (options&IGNORE_HANGUL)!=0,
UnicodeString::growBuffer, &result,
&status);
if(U_FAILURE(status)) {
result.setToBogus();
}
}
return;
}
/* ### end new implementation */
switch (mode) {
case NO_OP:
result = source;
@ -182,8 +202,7 @@ Normalizer::quickCheck(const UnicodeString& source,
if (U_FAILURE(status))
return UNORM_MAYBE;
const UChar *ps = source.getUChars();
return unorm_quickCheck(ps, source.length(),
return unorm_quickCheck(source.fArray, source.length(),
getUNormalizationMode(mode, status), &status);
}
@ -218,10 +237,29 @@ inline UBool isSetBitmask64(uint32_t* mask, int32_t bit) {
void
Normalizer::compose(const UnicodeString& source,
UBool compat,
int32_t,
int32_t options,
UnicodeString& result,
UErrorCode &status)
{
/* ### TODO: begin new implementation */
if(unorm_usesNewImplementation()) {
if(source.isBogus()) {
result.setToBogus();
} else {
/* make sure that we do not operate on the same buffer in source and result */
result.cloneArrayIfNeeded(-1, source.length()+20, FALSE);
result.fLength=unorm_compose(result.fArray, result.fCapacity,
source.fArray, source.fLength,
compat, (options&IGNORE_HANGUL)!=0,
UnicodeString::growBuffer, &result,
&status);
if(U_FAILURE(status)) {
result.setToBogus();
}
}
return;
}
/* ### end new implementation */
if (U_FAILURE(status)) {
return;
}

File diff suppressed because it is too large Load Diff

View File

@ -18,6 +18,7 @@
#define __UNORMIMP_H__
#include "unicode/utypes.h"
#include "unicode/unorm.h"
#include "ustr_imp.h"
/* trie constants */
@ -136,6 +137,18 @@ enum {
U_CAPI UBool U_EXPORT2
unorm_haveData(UErrorCode *pErrorCode);
/**
* Internal API for normalizing.
* Does not check for bad input and uses growBuffer.
* @internal
*/
U_CFUNC int32_t
unorm_internalNormalize(UChar *dest, int32_t destCapacity,
const UChar *src, int32_t srcLength,
UNormalizationMode mode, UBool ignoreHangul,
GrowBuffer *growBuffer, void *context,
UErrorCode *pErrorCode);
/**
* internal API, used by normlzr.cpp
* @internal
@ -147,6 +160,17 @@ unorm_decompose(UChar *dest, int32_t destCapacity,
GrowBuffer *growBuffer, void *context,
UErrorCode *pErrorCode);
/**
* internal API, used by normlzr.cpp
* @internal
*/
U_CFUNC int32_t
unorm_compose(UChar *dest, int32_t destCapacity,
const UChar *src, int32_t srcLength,
UBool compat, UBool ignoreHangul,
GrowBuffer *growBuffer, void *context,
UErrorCode *pErrorCode);
/**
* internal API, but used by tests
* @internal