mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
fix line break bug for halfwidth / fullwidth form
This commit is contained in:
parent
a6e438608c
commit
f83916aa40
@ -20,10 +20,10 @@
|
||||
mozilla/intl/lwbrk/tools/anzx4501.pl
|
||||
*/
|
||||
static PRUint32 gLBClass00[32] = {
|
||||
0x88888888, // U+0000 - U+0007
|
||||
0x88888888, // U+0008 - U+000F
|
||||
0x88888888, // U+0010 - U+0017
|
||||
0x88888888, // U+0018 - U+001F
|
||||
0x55555555, // U+0000 - U+0007
|
||||
0x55555555, // U+0008 - U+000F
|
||||
0x55555555, // U+0010 - U+0017
|
||||
0x55555555, // U+0018 - U+001F
|
||||
0x88438815, // U+0020 - U+0027
|
||||
0x81515810, // U+0028 - U+002F
|
||||
0x66666666, // U+0030 - U+0037
|
||||
|
@ -166,6 +166,18 @@ static PRUint16 gPair[MAX_CLASSES] = {
|
||||
#define GETCLASSFROMTABLE(t, l) ((((t)[(l>>3)]) >> ((l & 0x0007)<<2)) & 0x000f)
|
||||
|
||||
|
||||
|
||||
|
||||
#define IS_HALFWIDTH_IN_JISx4501_CLASS3(u) (\
|
||||
((0xff70 >= (u)) && ((u) >= 0xff76))|| \
|
||||
( 0xff79 == (u)) || \
|
||||
( 0xff82 == (u)) || \
|
||||
( 0xff94 == (u)) || \
|
||||
( 0xff95 == (u)) || \
|
||||
( 0xff96 == (u)) || \
|
||||
( 0xff9c == (u)) \
|
||||
)
|
||||
|
||||
PRInt8 nsJISx4501LineBreaker::GetClass(PRUnichar u)
|
||||
{
|
||||
PRUint16 h = u & 0xFF00;
|
||||
@ -177,15 +189,15 @@ PRInt8 nsJISx4501LineBreaker::GetClass(PRUnichar u)
|
||||
{
|
||||
c = GETCLASSFROMTABLE(gLBClass00, l);
|
||||
}
|
||||
else if( 0x0020 == h)
|
||||
else if( 0x2000 == h)
|
||||
{
|
||||
c = GETCLASSFROMTABLE(gLBClass20, l);
|
||||
}
|
||||
else if( 0x0021 == h)
|
||||
else if( 0x2100 == h)
|
||||
{
|
||||
c = GETCLASSFROMTABLE(gLBClass21, l);
|
||||
}
|
||||
else if( 0x0030 == h)
|
||||
else if( 0x3000 == h)
|
||||
{
|
||||
c = GETCLASSFROMTABLE(gLBClass30, l);
|
||||
} else if (( ( 0x3200 <= h) && ( h <= 0x33ff) ) ||
|
||||
@ -194,6 +206,32 @@ PRInt8 nsJISx4501LineBreaker::GetClass(PRUnichar u)
|
||||
)
|
||||
{
|
||||
c = 5; // CJK charcter, Han, and Han Compatability
|
||||
} else if( 0xff00 == h)
|
||||
{
|
||||
if( l < 0x0060) // Fullwidth ASCII variant
|
||||
{
|
||||
c = GETCLASSFROMTABLE(gLBClass00, (l+0x20));
|
||||
} else if (l < 0x00a0) {
|
||||
switch (l)
|
||||
{
|
||||
case 0x61: c = GetClass(0x3002); break;
|
||||
case 0x62: c = GetClass(0x300c); break;
|
||||
case 0x63: c = GetClass(0x300d); break;
|
||||
case 0x64: c = GetClass(0x3001); break;
|
||||
case 0x65: c = GetClass(0x30fb); break;
|
||||
case 0x9e: c = GetClass(0x309b); break;
|
||||
case 0x9f: c = GetClass(0x309c); break;
|
||||
default:
|
||||
if(IS_HALFWIDTH_IN_JISx4501_CLASS3(u))
|
||||
c = 1; // jis x4501 class 3
|
||||
else
|
||||
c = 5; // jis x4501 class 11
|
||||
break;
|
||||
};
|
||||
// Halfwidth Katakana variants
|
||||
} else {
|
||||
c = 8; // Halfwidth Hangul variants
|
||||
}
|
||||
} else {
|
||||
c = 8; // others
|
||||
}
|
||||
@ -299,7 +337,7 @@ NS_IMETHODIMP nsJISx4501LineBreaker::Next(
|
||||
if( aPos > aLen )
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
|
||||
if((aPos + 1) < aLen)
|
||||
if((aPos + 1) > aLen)
|
||||
{
|
||||
*oNext = aLen;
|
||||
*oNeedMoreText = PR_TRUE;
|
||||
@ -329,7 +367,7 @@ NS_IMETHODIMP nsJISx4501LineBreaker::Next(
|
||||
}
|
||||
|
||||
if(GetPair(c1, c2)) {
|
||||
*oNext = cur + 1;
|
||||
*oNext = cur ;
|
||||
*oNeedMoreText = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -244,15 +244,15 @@ Analysis of JIS x4501 to Unicode General Category Mapping
|
||||
<TD></TD>
|
||||
</TR>
|
||||
<TR><TH>05_[b]<TH>
|
||||
<TD></TD>
|
||||
<TD>32</TD>
|
||||
<TD>154</TD>
|
||||
<TD></TD>
|
||||
<TD>53</TD>
|
||||
<TD>3</TD>
|
||||
<TD>316</TD>
|
||||
<TD>2</TD>
|
||||
<TD BGCOLOR=white>528</TD>
|
||||
<TD></TD>
|
||||
<TD BGCOLOR=white>560</TD>
|
||||
<TD>32</TD>
|
||||
<TD></TD>
|
||||
<TD></TD>
|
||||
<TD></TD>
|
||||
@ -498,7 +498,7 @@ Analysis of JIS x4501 to Unicode General Category Mapping
|
||||
<TD></TD>
|
||||
<TD>3</TD>
|
||||
<TD>3</TD>
|
||||
<TD>13</TD>
|
||||
<TD>45</TD>
|
||||
<TD>10</TD>
|
||||
<TD></TD>
|
||||
<TD>149</TD>
|
||||
|
@ -141,6 +141,7 @@
|
||||
0030;0039;15
|
||||
2126;;16
|
||||
0020;;17
|
||||
0000;001f;17
|
||||
0021;007E;18
|
||||
00A1;00FF;18
|
||||
0100;017F;18
|
||||
|
Loading…
Reference in New Issue
Block a user