From 70abf0a046a7b8e024d03eaf8ecf4e689bd491de Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Fri, 25 Mar 2005 16:08:54 +0400 Subject: Allow inserting of extra HKSCS and cp950 characters into a Big5 column. --- strings/ctype-big5.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'strings') diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index 270b02212af..58847a96591 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -6271,6 +6271,43 @@ my_mb_wc_big5(CHARSET_INFO *cs __attribute__((unused)), return 2; } + +/* + Returns a well formed length of a BIG5 string. + CP950 and HKSCS additional characters are also accepted. +*/ +static +uint my_well_formed_len_big5(CHARSET_INFO *cs __attribute__((unused)), + const char *b, const char *e, uint pos) +{ + const char *b0= b; + const char *emb= e - 1; /* Last possible end of an MB character */ + while (pos && b < e) + { + /* + Cast to int8 for extra safety. "char" can be unsigned + by default on some platforms. + */ + if (((int8)b[0]) >= 0) + { + /* Single byte ascii character */ + b++; + } + else if ((b < emb) && isbig5code((uchar)*b, (uchar)b[1])) + { + /* Double byte character */ + b+= 2; + } + else + { + /* Wrong byte sequence */ + break; + } + } + return b - b0; +} + + static MY_COLLATION_HANDLER my_collation_big5_chinese_ci_handler = { NULL, /* init */ @@ -6291,7 +6328,7 @@ static MY_CHARSET_HANDLER my_charset_big5_handler= mbcharlen_big5, my_numchars_mb, my_charpos_mb, - my_well_formed_len_mb, + my_well_formed_len_big5, my_lengthsp_8bit, my_numcells_8bit, my_mb_wc_big5, /* mb_wc */ -- cgit v1.2.1