From: tomo Date: Thu, 7 Aug 2003 00:41:54 +0000 (+0000) Subject: (chise_ft_get_value): Use escape forms for some special characters. X-Git-Tag: r0_1_1-pre1~12 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=553bb7165ab4ce49ea0411804613ba9950d83aac;p=chise%2Flibchise.git (chise_ft_get_value): Use escape forms for some special characters. --- diff --git a/chise.c b/chise.c index c24fd8e..3397991 100644 --- a/chise.c +++ b/chise.c @@ -170,49 +170,110 @@ int chise_ft_get_value (CHISE_Feature_Table *db, unsigned char key_buf[8]; key_buf[0] = '?'; - if (cid <= 0x7f) + if (cid == '\t') + { + key_buf[1] = '\\'; + key_buf[2] = 't'; + key_buf[3] = '\0'; + } + else if (cid == '\n') + { + key_buf[1] = '\\'; + key_buf[2] = 'n'; + key_buf[3] = '\0'; + } + else if (cid == '\r') + { + key_buf[1] = '\\'; + key_buf[2] = 'r'; + key_buf[3] = '\0'; + } + else if (cid == 0x1C) + { + key_buf[1] = '\\'; + key_buf[2] = '^'; + key_buf[3] = '\\'; + key_buf[4] = '\\'; + key_buf[5] = '\0'; + } + else if (cid <= 0x1F) + { + key_buf[1] = '\\'; + key_buf[2] = '^'; + key_buf[3] = '@' + cid; + key_buf[4] = '\0'; + } + else if ( (cid == ' ') || (cid == '"') || + (cid == '#') || (cid == '\'') || + (cid == '(') || (cid == ')') || + (cid == ',') || (cid == '.') || + (cid == ';') || (cid == '?') || + (cid == '[') || (cid == '\\') || + (cid == ']') || (cid == '`') ) + { + key_buf[1] = '\\'; + key_buf[2] = cid; + key_buf[3] = '\0'; + } + else if (cid <= 0x7E) { key_buf[1] = cid; key_buf[2] = '\0'; } - else if (cid <= 0x7ff) + else if (cid == 0x7F) + { + key_buf[1] = '\\'; + key_buf[2] = '^'; + key_buf[3] = '?'; + key_buf[4] = '\0'; + } + else if (cid <= 0x9F) + { + key_buf[1] = '\\'; + key_buf[2] = '^'; + key_buf[3] = ((cid + '@') >> 6) | 0xC0; + key_buf[4] = ((cid + '@') & 0x3F) | 0x80; + key_buf[5] = '\0'; + + } + else if (cid <= 0x7FF) { - key_buf[1] = (cid >> 6) | 0xc0; - key_buf[2] = (cid & 0x3f) | 0x80; + key_buf[1] = (cid >> 6) | 0xC0; + key_buf[2] = (cid & 0x3F) | 0x80; key_buf[3] = '\0'; } - else if (cid <= 0xffff) + else if (cid <= 0xFFFF) { - key_buf[1] = (cid >> 12) | 0xe0; - key_buf[2]= ((cid >> 6) & 0x3f) | 0x80; - key_buf[3]= (cid & 0x3f) | 0x80; + key_buf[1] = (cid >> 12) | 0xE0; + key_buf[2]= ((cid >> 6) & 0x3F) | 0x80; + key_buf[3]= (cid & 0x3F) | 0x80; key_buf[4] = '\0'; } - else if (cid <= 0x1fffff) + else if (cid <= 0x1FFFFF) { - key_buf[1]= (cid >> 18) | 0xf0; - key_buf[2]= ((cid >> 12) & 0x3f) | 0x80; - key_buf[3]= ((cid >> 6) & 0x3f) | 0x80; - key_buf[4]= (cid & 0x3f) | 0x80; + key_buf[1]= (cid >> 18) | 0xF0; + key_buf[2]= ((cid >> 12) & 0x3F) | 0x80; + key_buf[3]= ((cid >> 6) & 0x3F) | 0x80; + key_buf[4]= (cid & 0x3F) | 0x80; key_buf[5] = '\0'; } - else if (cid <= 0x3ffffff) + else if (cid <= 0x3FFFFFF) { - key_buf[1]= (cid >> 24) | 0xf8; - key_buf[2]= ((cid >> 18) & 0x3f) | 0x80; - key_buf[3]= ((cid >> 12) & 0x3f) | 0x80; - key_buf[4]= ((cid >> 6) & 0x3f) | 0x80; - key_buf[5]= (cid & 0x3f) | 0x80; + key_buf[1]= (cid >> 24) | 0xF8; + key_buf[2]= ((cid >> 18) & 0x3F) | 0x80; + key_buf[3]= ((cid >> 12) & 0x3F) | 0x80; + key_buf[4]= ((cid >> 6) & 0x3F) | 0x80; + key_buf[5]= (cid & 0x3F) | 0x80; key_buf[6] = '\0'; } else { - key_buf[1]= (cid >> 30) | 0xfc; - key_buf[2]= ((cid >> 24) & 0x3f) | 0x80; - key_buf[3]= ((cid >> 18) & 0x3f) | 0x80; - key_buf[4]= ((cid >> 12) & 0x3f) | 0x80; - key_buf[5]= ((cid >> 6) & 0x3f) | 0x80; - key_buf[6]= (cid & 0x3f) | 0x80; + key_buf[1]= (cid >> 30) | 0xFC; + key_buf[2]= ((cid >> 24) & 0x3F) | 0x80; + key_buf[3]= ((cid >> 18) & 0x3F) | 0x80; + key_buf[4]= ((cid >> 12) & 0x3F) | 0x80; + key_buf[5]= ((cid >> 6) & 0x3F) | 0x80; + key_buf[6]= (cid & 0x3F) | 0x80; key_buf[7] = '\0'; } return