ICU-1000 another try at Jamo specials. Think I got them right now. Still needs another iteration for the situation when we are already in the normalization buffer
X-SVN-Rev: 5938
This commit is contained in:
parent
1305c4495f
commit
ede2afe7ad
@ -2008,47 +2008,53 @@ uint32_t getSpecialCE(const UCollator *coll, UChar ch, uint32_t CE, collIterate
|
||||
return ucmpe32_get(UCA->mapping, L); // return first one
|
||||
|
||||
} else { // Jamo is Special
|
||||
//collIterate jamos;
|
||||
//UChar jamoString[3];
|
||||
uint32_t CE = UCOL_NOT_FOUND;
|
||||
const UCollator *collator = source->coll;
|
||||
// Move Jamos into normalization buffer
|
||||
source->writableBuffer[0] = (UChar)L;
|
||||
source->writableBuffer[1] = (UChar)V;
|
||||
// TODO: if we are already in the normalization buffer,
|
||||
// and we encounter a Hangul with Jamo special set to
|
||||
// TRUE, we currently fallback to old implementation.
|
||||
// What needs to be done is to replace the Hangul by
|
||||
// 2 or 3 Jamos and move the rest of the normalization
|
||||
// buffer accordingly.
|
||||
if(!((source->flags) & UCOL_ITER_INNORMBUF)) {
|
||||
// Move Jamos into normalization buffer
|
||||
source->writableBuffer[0] = (UChar)L;
|
||||
source->writableBuffer[1] = (UChar)V;
|
||||
if (T != TBase) {
|
||||
source->writableBuffer[2] = (UChar)T;
|
||||
source->writableBuffer[3] = 0;
|
||||
} else {
|
||||
source->writableBuffer[2] = 0;
|
||||
}
|
||||
|
||||
source->fcdPosition = source->pos+1; // Indicate where to continue in main input string
|
||||
// after exhausting the writableBuffer
|
||||
source->pos = source->writableBuffer;
|
||||
source->origFlags = source->flags;
|
||||
source->flags |= UCOL_ITER_INNORMBUF;
|
||||
source->flags &= ~(UCOL_ITER_NORM | UCOL_ITER_HASLEN);
|
||||
source->fcdPosition = source->pos; // Indicate where to continue in main input string
|
||||
// after exhausting the writableBuffer
|
||||
source->pos = source->writableBuffer;
|
||||
source->origFlags = source->flags;
|
||||
source->flags |= UCOL_ITER_INNORMBUF;
|
||||
source->flags &= ~(UCOL_ITER_NORM | UCOL_ITER_HASLEN);
|
||||
|
||||
if (T != TBase) {
|
||||
source->writableBuffer[2] = (UChar)T;
|
||||
source->writableBuffer[3] = 0;
|
||||
return(UCOL_IGNORABLE);
|
||||
} else {
|
||||
source->writableBuffer[2] = 0;
|
||||
}
|
||||
collIterate jamos;
|
||||
UChar jamoString[3];
|
||||
uint32_t CE = UCOL_NOT_FOUND;
|
||||
const UCollator *collator = source->coll;
|
||||
jamoString[0] = (UChar)L;
|
||||
jamoString[1] = (UChar)V;
|
||||
if (T != TBase) {
|
||||
jamoString[2] = (UChar)T;
|
||||
IInit_collIterate(collator, jamoString, 3, &jamos);
|
||||
} else {
|
||||
IInit_collIterate(collator, jamoString, 2, &jamos);
|
||||
}
|
||||
|
||||
CE = UCOL_IGNORABLE;
|
||||
/*
|
||||
jamoString[0] = (UChar)L;
|
||||
jamoString[1] = (UChar)V;
|
||||
if (T != TBase) {
|
||||
jamoString[2] = (UChar)T;
|
||||
IInit_collIterate(collator, jamoString, 3, &jamos);
|
||||
} else {
|
||||
IInit_collIterate(collator, jamoString, 2, &jamos);
|
||||
}
|
||||
|
||||
CE = ucol_IGetNextCE(collator, &jamos, status);
|
||||
|
||||
while(CE != UCOL_NO_MORE_CES) {
|
||||
*(source->CEpos++) = CE;
|
||||
CE = ucol_IGetNextCE(collator, &jamos, status);
|
||||
|
||||
while(CE != UCOL_NO_MORE_CES) {
|
||||
*(source->CEpos++) = CE;
|
||||
CE = ucol_IGetNextCE(collator, &jamos, status);
|
||||
}
|
||||
return *(source->toReturn++);
|
||||
}
|
||||
return *(source->toReturn++);
|
||||
*/
|
||||
}
|
||||
}
|
||||
case CHARSET_TAG:
|
||||
@ -2362,9 +2368,8 @@ uint32_t getSpecialPrevCE(const UCollator *coll, UChar ch, uint32_t CE,
|
||||
*/
|
||||
if (source->pos - 1 == source->string) {
|
||||
source->fcdPosition = NULL;
|
||||
}
|
||||
else {
|
||||
source->fcdPosition = source->pos - 2;
|
||||
} else {
|
||||
source->fcdPosition = source->pos-2;
|
||||
}
|
||||
|
||||
source->pos = tempbuffer;
|
||||
@ -2372,7 +2377,8 @@ uint32_t getSpecialPrevCE(const UCollator *coll, UChar ch, uint32_t CE,
|
||||
source->flags |= UCOL_ITER_INNORMBUF;
|
||||
source->flags &= ~(UCOL_ITER_NORM | UCOL_ITER_HASLEN);
|
||||
|
||||
CE = UCOL_IGNORABLE;
|
||||
//CE = UCOL_IGNORABLE;
|
||||
return(UCOL_IGNORABLE);
|
||||
}
|
||||
break;
|
||||
case CONTRACTION_TAG:
|
||||
@ -2514,62 +2520,70 @@ uint32_t getSpecialPrevCE(const UCollator *coll, UChar ch, uint32_t CE,
|
||||
source->toReturn = source->CEpos - 1;
|
||||
return *(source->toReturn);
|
||||
} else {
|
||||
// TODO: if we are already in the normalization buffer,
|
||||
// and we encounter a Hangul with Jamo special set to
|
||||
// TRUE, we currently fallback to old implementation.
|
||||
// What needs to be done is to replace the Hangul by
|
||||
// 2 or 3 Jamos and move the rest of the normalization
|
||||
// buffer accordingly.
|
||||
if(!((source->flags) & UCOL_ITER_INNORMBUF)) {
|
||||
/*
|
||||
Move the Jamos into the
|
||||
normalization buffer
|
||||
*/
|
||||
UChar *tempbuffer = source->writableBuffer +
|
||||
(source->writableBufSize - 1);
|
||||
*(tempbuffer) = 0;
|
||||
if (T != TBase) {
|
||||
*(tempbuffer - 1) = (UChar)T;
|
||||
*(tempbuffer - 2) = (UChar)V;
|
||||
*(tempbuffer - 3) = (UChar)L;
|
||||
*(tempbuffer - 4) = 0;
|
||||
} else {
|
||||
*(tempbuffer - 1) = (UChar)V;
|
||||
*(tempbuffer - 2) = (UChar)L;
|
||||
*(tempbuffer - 3) = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Move the prevowel and the following base Consonant into the
|
||||
normalization buffer with their order swapped
|
||||
*/
|
||||
UChar *tempbuffer = source->writableBuffer +
|
||||
(source->writableBufSize - 1);
|
||||
*(tempbuffer) = (UChar)L;
|
||||
*(tempbuffer - 1) = (UChar)V;
|
||||
|
||||
/*
|
||||
Indicate where to continue in main input string after exhausting
|
||||
the writableBuffer
|
||||
*/
|
||||
if (source->pos - 1 == source->string) {
|
||||
/*
|
||||
Indicate where to continue in main input string after exhausting
|
||||
the writableBuffer
|
||||
*/
|
||||
if (source->pos == source->string) {
|
||||
source->fcdPosition = NULL;
|
||||
}
|
||||
else {
|
||||
source->fcdPosition = source->pos - 1;
|
||||
}
|
||||
} else {
|
||||
source->fcdPosition = source->pos-1;
|
||||
}
|
||||
|
||||
source->pos = tempbuffer;
|
||||
source->origFlags = source->flags;
|
||||
source->flags |= UCOL_ITER_INNORMBUF;
|
||||
source->flags &= ~(UCOL_ITER_NORM | UCOL_ITER_HASLEN);
|
||||
source->pos = tempbuffer;
|
||||
source->origFlags = source->flags;
|
||||
source->flags |= UCOL_ITER_INNORMBUF;
|
||||
source->flags &= ~(UCOL_ITER_NORM | UCOL_ITER_HASLEN);
|
||||
|
||||
if (T != TBase) {
|
||||
*(tempbuffer - 2) = (UChar)T;
|
||||
*(tempbuffer - 3) = 0;
|
||||
return(UCOL_IGNORABLE);
|
||||
} else {
|
||||
*(tempbuffer - 2) = 0;
|
||||
}
|
||||
CE = UCOL_IGNORABLE;
|
||||
/*
|
||||
collIterate jamos;
|
||||
UChar jamoString[3];
|
||||
uint32_t CE = UCOL_NOT_FOUND;
|
||||
const UCollator *collator = source->coll;
|
||||
jamoString[0] = (UChar)L;
|
||||
jamoString[1] = (UChar)V;
|
||||
if (T != TBase) {
|
||||
jamoString[2] = (UChar)T;
|
||||
IInit_collIterate(collator, jamoString, 3, &jamos);
|
||||
} else {
|
||||
IInit_collIterate(collator, jamoString, 2, &jamos);
|
||||
}
|
||||
collIterate jamos;
|
||||
UChar jamoString[3];
|
||||
uint32_t CE = UCOL_NOT_FOUND;
|
||||
const UCollator *collator = source->coll;
|
||||
jamoString[0] = (UChar)L;
|
||||
jamoString[1] = (UChar)V;
|
||||
if (T != TBase) {
|
||||
jamoString[2] = (UChar)T;
|
||||
IInit_collIterate(collator, jamoString, 3, &jamos);
|
||||
} else {
|
||||
IInit_collIterate(collator, jamoString, 2, &jamos);
|
||||
}
|
||||
|
||||
CE = ucol_IGetNextCE(collator, &jamos, status);
|
||||
|
||||
while(CE != UCOL_NO_MORE_CES) {
|
||||
*(source->CEpos++) = CE;
|
||||
CE = ucol_IGetNextCE(collator, &jamos, status);
|
||||
|
||||
while(CE != UCOL_NO_MORE_CES) {
|
||||
*(source->CEpos++) = CE;
|
||||
CE = ucol_IGetNextCE(collator, &jamos, status);
|
||||
}
|
||||
source->toReturn = source->CEpos - 1;
|
||||
return *(source->toReturn);
|
||||
}
|
||||
source->toReturn = source->CEpos - 1;
|
||||
return *(source->toReturn);
|
||||
*/
|
||||
}
|
||||
}
|
||||
case LEAD_SURROGATE_TAG: /* D800-DBFF*/
|
||||
|
Loading…
Reference in New Issue
Block a user