mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-08 15:05:53 +00:00
ICU-1245 adding both composed and decomposed form of contraction
X-SVN-Rev: 6437
This commit is contained in:
parent
ab4045e909
commit
899b56f176
2 changed files with 38 additions and 2 deletions
|
@ -824,6 +824,25 @@ U_CFUNC void ucol_createElements(UColTokenParser *src, tempUCATable *t, UColTokL
|
|||
fprintf(stderr, "Adding: %04X with %08X\n", el.cPoints[0], el.CEs[0]);
|
||||
#endif
|
||||
uprv_uca_addAnElement(t, &el, status);
|
||||
|
||||
#if 0
|
||||
if(el.cSize > 1) { // this is a contraction, we should check whether a composed form should also be included
|
||||
UChar composed[256];
|
||||
uint32_t compLen = unorm_normalize(el.cPoints, el.cSize, UNORM_NFC, 0, composed, 256, status);;
|
||||
|
||||
if(compLen != el.cSize || uprv_memcmp(composed, el.cPoints, el.cSize*sizeof(UChar))) {
|
||||
// composed form of a contraction is different than the decomposed form!
|
||||
// do it!
|
||||
#ifdef UCOL_DEBUG
|
||||
fprintf(stderr, "Adding composed for %04X->%04X\n", *element->cPoints, *composed);
|
||||
#endif
|
||||
el.cSize = compLen;
|
||||
uprv_memcpy(el.cPoints, composed, el.cSize*sizeof(UChar));
|
||||
uprv_uca_addAnElement(t, &el, status);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if UCOL_DEBUG_DUPLICATES
|
||||
if(*status != U_ZERO_ERROR) {
|
||||
fprintf(stderr, "replaced CE for %04X with CE for %04X\n", el.cPoints[0], tok->debugSource);
|
||||
|
|
|
@ -843,7 +843,7 @@ static uint32_t uprv_uca_finalizeAddition(tempUCATable *t, UCAElements *element,
|
|||
|
||||
UTF_NEXT_CHAR(element->cPoints, i, element->cSize, cp);
|
||||
CE = ucmpe32_get(t->mapping, cp);
|
||||
|
||||
#if 0
|
||||
UCAElements *composed = (UCAElements *)uprv_malloc(sizeof(UCAElements));
|
||||
uprv_memcpy(composed, element, sizeof(UCAElements));
|
||||
composed->cPoints = composed->uchars;
|
||||
|
@ -858,13 +858,14 @@ static uint32_t uprv_uca_finalizeAddition(tempUCATable *t, UCAElements *element,
|
|||
#endif
|
||||
}
|
||||
uprv_free(composed);
|
||||
#endif
|
||||
|
||||
CE = uprv_uca_addContraction(t, CE, element, status);
|
||||
} else { /* easy case, */
|
||||
CE = ucmpe32_get(t->mapping, element->cPoints[0]);
|
||||
|
||||
if( CE != UCOL_NOT_FOUND) {
|
||||
if(isCntTableElement(CE) /*isContraction(CE)*/) { /* adding a non contraction element (thai, expansion, single) to already existing contraction */
|
||||
if(/*isCntTableElement(CE)*/ isContraction(CE)) { /* adding a non contraction element (thai, expansion, single) to already existing contraction */
|
||||
uprv_cnttab_setContraction(t->contractions, CE, 0, 0, element->mapCE, status);
|
||||
/* This loop has to change the CE at the end of contraction REDO!*/
|
||||
uprv_cnttab_changeLastCE(t->contractions, CE, element->mapCE, status);
|
||||
|
@ -971,6 +972,22 @@ uint32_t uprv_uca_addAnElement(tempUCATable *t, UCAElements *element, UErrorCode
|
|||
|
||||
CE = uprv_uca_finalizeAddition(t, element, status);
|
||||
|
||||
if(element->cSize > 1) { // this is a contraction, we should check whether a composed form should also be included
|
||||
UChar composed[256];
|
||||
uint32_t compLen = unorm_normalize(element->cPoints, element->cSize, UNORM_NFC, 0, composed, 256, status);;
|
||||
|
||||
if(compLen != element->cSize || uprv_memcmp(composed, element->cPoints, element->cSize*sizeof(UChar))) {
|
||||
// composed form of a contraction is different than the decomposed form!
|
||||
// do it!
|
||||
#ifdef UCOL_DEBUG
|
||||
fprintf(stderr, "Adding composed for %04X->%04X\n", *element->cPoints, *composed);
|
||||
#endif
|
||||
element->cSize = compLen;
|
||||
uprv_memcpy(element->cPoints, composed, element->cSize*sizeof(UChar));
|
||||
uprv_uca_finalizeAddition(t, element, status);
|
||||
}
|
||||
}
|
||||
|
||||
return CE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue