diff options
author | unknown <bar@mysql.com> | 2005-07-22 21:06:02 +0500 |
---|---|---|
committer | unknown <bar@mysql.com> | 2005-07-22 21:06:02 +0500 |
commit | bf45b6ba8477a9a910ec530c126569c208d5c0a1 (patch) | |
tree | aacef1124ec67f869a024b22366f1891b9e2ce88 /strings | |
parent | a68a2da0e762ff5bfac1075a52b63b2bbced2b04 (diff) | |
download | mariadb-git-bf45b6ba8477a9a910ec530c126569c208d5c0a1.tar.gz |
ctype-gbk.c:
Bug #11987
mysql will truncate the text when the text contain GBK char:"0xA3A0" and "0xA1"
Allow to store and retrieve even unassigned GBK codes.
Like we did in Big5 earlier.
have_gbk.inc, have_gbk.require, ctype_gbk.result, ctype_gbk.test:
new file
strings/ctype-gbk.c:
Bug #11987
mysql will truncate the text when the text contain GBK char:"0xA3A0" and "0xA1"
Allow to store and retrieve even unassigned GBK codes.
Like we did in Big5 earlier.
Diffstat (limited to 'strings')
-rw-r--r-- | strings/ctype-gbk.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c index 89d28320fe1..6fb072d266d 100644 --- a/strings/ctype-gbk.c +++ b/strings/ctype-gbk.c @@ -9925,6 +9925,43 @@ my_mb_wc_gbk(CHARSET_INFO *cs __attribute__((unused)), } +/* + Returns well formed length of a GBK string. +*/ +static +uint my_well_formed_len_gbk(CHARSET_INFO *cs __attribute__((unused)), + const char *b, const char *e, + uint pos, int *error) +{ + const char *b0= b; + const char *emb= e - 1; /* Last possible end of an MB character */ + + *error= 0; + while (pos-- && b < e) + { + if ((uchar) b[0] < 128) + { + /* Single byte ascii character */ + b++; + } + else if ((b < emb) && isgbkcode((uchar)*b, (uchar)b[1])) + { + /* Double byte character */ + b+= 2; + } + else + { + /* Wrong byte sequence */ + *error= 1; + break; + } + } + return b - b0; +} + + + + static MY_COLLATION_HANDLER my_collation_ci_handler = { NULL, /* init */ @@ -9945,7 +9982,7 @@ static MY_CHARSET_HANDLER my_charset_handler= mbcharlen_gbk, my_numchars_mb, my_charpos_mb, - my_well_formed_len_mb, + my_well_formed_len_gbk, my_lengthsp_8bit, my_numcells_8bit, my_mb_wc_gbk, |