[CP] [FEAT MERGE]字符集从42xrelease分支 patch 合入master分支
This commit is contained in:
@ -235,69 +235,78 @@ char *parse_strdup_with_replace_multi_byte_char(const char *str, int *connection
|
||||
int64_t len = 0;
|
||||
int64_t dup_len = strlen(str);
|
||||
for (int64_t i = 0; i < dup_len; ++i) {
|
||||
switch (*connection_collation_) {
|
||||
case 28/*CS_TYPE_GBK_CHINESE_CI*/:
|
||||
case 87/*CS_TYPE_GBK_BIN*/:
|
||||
case 216/*CS_TYPE_GB18030_2022_BIN*/:
|
||||
case 217/*CS_TYPE_GB18030_2022_PINYIN_CI*/:
|
||||
case 218/*CS_TYPE_GB18030_2022_PINYIN_CS*/:
|
||||
case 219/*CS_TYPE_GB18030_2022_RADICAL_CI*/:
|
||||
case 220/*CS_TYPE_GB18030_2022_RADICAL_CS*/:
|
||||
case 221/*CS_TYPE_GB18030_2022_STROKE_CI*/:
|
||||
case 222/*CS_TYPE_GB18030_2022_STROKE_CS*/:
|
||||
case 248/*CS_TYPE_GB18030_CHINESE_CI*/:
|
||||
case 249/*CS_TYPE_GB18030_BIN*/: {
|
||||
if (i + 1 < dup_len) {
|
||||
if (str[i] == (char)0xa1 && str[i+1] == (char)0xa1) {//gbk multi byte space
|
||||
out_str[len++] = ' ';
|
||||
++i;
|
||||
} else if (str[i] == (char)0xa3 && str[i+1] == (char)0xa8) {
|
||||
//gbk multi byte left parenthesis
|
||||
out_str[len++] = '(';
|
||||
++i;
|
||||
} else if (str[i] == (char)0xa3 && str[i+1] == (char)0xa9) {
|
||||
//gbk multi byte right parenthesis
|
||||
out_str[len++] = ')';
|
||||
++i;
|
||||
} else {
|
||||
out_str[len++] = str[i];
|
||||
}
|
||||
if (*connection_collation_ == 28/*CS_TYPE_GBK_CHINESE_CI*/
|
||||
|| *connection_collation_ == 87/*CS_TYPE_GBK_BIN*/
|
||||
|| *connection_collation_ == 248/*CS_TYPE_GB18030_CHINESE_CI*/
|
||||
|| *connection_collation_ == 249/*CS_TYPE_GB18030_BIN*/
|
||||
|| (*connection_collation_ >= 216/*CS_TYPE_GB18030_2022_BIN*/
|
||||
&& *connection_collation_ <= 222/*CS_TYPE_GB18030_2022_STROKE_CS*/)) {
|
||||
if (i + 1 < dup_len) {
|
||||
if (str[i] == (char)0xa1 && str[i+1] == (char)0xa1) {//gbk multi byte space
|
||||
out_str[len++] = ' ';
|
||||
++i;
|
||||
} else if (str[i] == (char)0xa3 && str[i+1] == (char)0xa8) {
|
||||
//gbk multi byte left parenthesis
|
||||
out_str[len++] = '(';
|
||||
++i;
|
||||
} else if (str[i] == (char)0xa3 && str[i+1] == (char)0xa9) {
|
||||
//gbk multi byte right parenthesis
|
||||
out_str[len++] = ')';
|
||||
++i;
|
||||
} else {
|
||||
out_str[len++] = str[i];
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
out_str[len++] = str[i];
|
||||
}
|
||||
case 45/*CS_TYPE_UTF8MB4_GENERAL_CI*/:
|
||||
case 46/*CS_TYPE_UTF8MB4_BIN*/:
|
||||
case 63/*CS_TYPE_BINARY*/:
|
||||
case 224/*CS_TYPE_UTF8MB4_UNICODE_CI*/:
|
||||
case 245/*CS_TYPE_UTF8MB4_CROATIAN_CI*/:
|
||||
case 246/*CS_TYPE_UTF8MB4_UNICODE_520_CI*/:
|
||||
case 234/*CS_TYPE_UTF8MB4_CZECH_CI*/:
|
||||
case 255/*CS_TYPE_UTF8MB4_0900_AI_CI*/:
|
||||
{
|
||||
if (i + 2 < dup_len) {
|
||||
if (str[i] == (char)0xe3 && str[i+1] == (char)0x80 && str[i+2] == (char)0x80) {
|
||||
//utf8 multi byte space
|
||||
out_str[len++] = ' ';
|
||||
i = i + 2;
|
||||
} else if (str[i] == (char)0xef && str[i+1] == (char)0xbc && str[i+2] == (char)0x88) {
|
||||
//utf8 multi byte left parenthesis
|
||||
out_str[len++] = '(';
|
||||
i = i + 2;
|
||||
} else if (str[i] == (char)0xef && str[i+1] == (char)0xbc && str[i+2] == (char)0x89) {
|
||||
//utf8 multi byte right parenthesis
|
||||
out_str[len++] = ')';
|
||||
i = i + 2;
|
||||
} else {
|
||||
out_str[len++] = str[i];
|
||||
}
|
||||
} else if (
|
||||
*connection_collation_ == 45/*CS_TYPE_UTF8MB4_GENERAL_CI*/
|
||||
|| *connection_collation_ == 46/*CS_TYPE_UTF8MB4_BIN*/
|
||||
|| *connection_collation_ == 63/*CS_TYPE_BINARY*/
|
||||
|| *connection_collation_ == 255/*CS_TYPE_UTF8MB4_0900_AI_CI*/
|
||||
|| (*connection_collation_ >= 224/*CS_TYPE_UTF8MB4_UNICODE_CI*/
|
||||
&& *connection_collation_ <= 247/*CS_TYPE_UTF8MB4_VIETNAMESE_CI*/)) {
|
||||
if (i + 2 < dup_len) {
|
||||
if (str[i] == (char)0xe3 && str[i+1] == (char)0x80 && str[i+2] == (char)0x80) {
|
||||
//utf8 multi byte space
|
||||
out_str[len++] = ' ';
|
||||
i = i + 2;
|
||||
} else if (str[i] == (char)0xef && str[i+1] == (char)0xbc && str[i+2] == (char)0x88) {
|
||||
//utf8 multi byte left parenthesis
|
||||
out_str[len++] = '(';
|
||||
i = i + 2;
|
||||
} else if (str[i] == (char)0xef && str[i+1] == (char)0xbc && str[i+2] == (char)0x89) {
|
||||
//utf8 multi byte right parenthesis
|
||||
out_str[len++] = ')';
|
||||
i = i + 2;
|
||||
} else {
|
||||
out_str[len++] = str[i];
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
out_str[len++] = str[i];
|
||||
}
|
||||
default:
|
||||
} else if (
|
||||
*connection_collation_ == 152
|
||||
|| *connection_collation_ == 153) {
|
||||
if (i + 1 < dup_len) {
|
||||
if (str[i] == (char)0xa1 && str[i+1] == (char)0x40) {//hkscs multi byte space
|
||||
out_str[len++] = ' ';
|
||||
++i;
|
||||
} else if (str[i] == (char)0xa1 && str[i+1] == (char)0x5d) {
|
||||
//hkscs multi byte left parenthesis
|
||||
out_str[len++] = '(';
|
||||
++i;
|
||||
} else if (str[i] == (char)0xa1 && str[i+1] == (char)0x5e) {
|
||||
//hkscs multi byte right parenthesis
|
||||
out_str[len++] = ')';
|
||||
++i;
|
||||
} else {
|
||||
out_str[len++] = str[i];
|
||||
}
|
||||
} else {
|
||||
out_str[len++] = str[i];
|
||||
}
|
||||
} else {
|
||||
out_str[len++] = str[i];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user