summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog12
-rw-r--r--enc/big5.c79
2 files changed, 86 insertions, 5 deletions
@@ -1,3 +1,15 @@
Tue Aug 4 09:33:54 2009 NARUSE, Yui <[email protected]>
* encoding.c (rb_enc_set_base): Add for setting base encoding
@@ -30,6 +30,24 @@
#include "regenc.h"
static const int EncLen_BIG5[] = {
/* LEN 0 1 2 3 4 5 6 7 8 9 A B C D E F */
/* 0 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
/* 1 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -88,26 +106,56 @@ static const signed char trans[][0x100] = {
/* d */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
/* e */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,
/* f */ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, F
}
};
#undef A
#undef F
static int
-big5_mbc_enc_len(const UChar* p, const UChar* e, OnigEncoding enc ARG_UNUSED)
{
int firstbyte = *p++;
- state_t s = trans[0][firstbyte];
#define RETURN(n) \
return s == ACCEPT ? ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(n) : \
ONIGENC_CONSTRUCT_MBCLEN_INVALID()
if (s < 0) RETURN(1);
- if (p == e) return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(EncLen_BIG5[firstbyte]-1);
s = trans[s][*p++];
RETURN(2);
#undef RETURN
}
static OnigCodePoint
big5_mbc_to_code(const UChar* p, const UChar* end, OnigEncoding enc)
{
@@ -162,7 +210,11 @@ static const char BIG5_CAN_BE_TRAIL_TABLE[256] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0
};
-#define BIG5_ISMB_FIRST(byte) (EncLen_BIG5[byte] > 1)
#define BIG5_ISMB_TRAIL(byte) BIG5_CAN_BE_TRAIL_TABLE[(byte)]
static UChar*
@@ -229,5 +281,22 @@ ENC_ALIAS("CP950", "Big5")
* Source: See (http://www.iana.org/assignments/charset-reg/Big5-HKSCS)
* Alias: None
*/
-ENC_REPLICATE("Big5-HKSCS", "Big5")
ENC_ALIAS("CP951", "Big5-HKSCS")