| 1 | /* |
|---|
| 2 | * KAKASI (Kanji Kana Simple inversion program) |
|---|
| 3 | * $Id: k2.c,v 1.3 2001/01/16 07:51:47 rug Exp $ |
|---|
| 4 | * Copyright (C) 1992 |
|---|
| 5 | * Hironobu Takahashi (takahasi@tiny.or.jp) |
|---|
| 6 | * |
|---|
| 7 | * This program is free software; you can redistribute it and/or modify |
|---|
| 8 | * it under the terms of the GNU General Public License as published by |
|---|
| 9 | * the Free Software Foundation; either versions 2, or (at your option) |
|---|
| 10 | * any later version. |
|---|
| 11 | * |
|---|
| 12 | * This program is distributed in the hope that it will be useful |
|---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 15 | * GNU General Public License for more details. |
|---|
| 16 | * |
|---|
| 17 | * You should have received a copy of the GNU General Public License |
|---|
| 18 | * along with KAKASI, see the file COPYING. If not, write to the Free |
|---|
| 19 | * Software Foundation Inc., 59 Temple Place - Suite 330, Boston, MA |
|---|
| 20 | * 02111-1307, USA. |
|---|
| 21 | */ |
|---|
| 22 | |
|---|
| 23 | #ifdef HAVE_CONFIG_H |
|---|
| 24 | # include <config.h> |
|---|
| 25 | #endif |
|---|
| 26 | |
|---|
| 27 | #include <stdio.h> |
|---|
| 28 | #ifdef HAVE_STRING_H |
|---|
| 29 | # include <string.h> |
|---|
| 30 | #else |
|---|
| 31 | # include <strings.h> |
|---|
| 32 | #endif |
|---|
| 33 | #include "kakasi.h" |
|---|
| 34 | |
|---|
| 35 | struct k2rom_tbl { |
|---|
| 36 | char kana[5]; |
|---|
| 37 | char romaji[7]; |
|---|
| 38 | } |
|---|
| 39 | k2rom_h_table[] = { |
|---|
| 40 | " ", " ", "!", ".", "\"", "(", "#", ")", "$", ",", "%", ".", "&", |
|---|
| 41 | "wo","'", "a","(", "i",")", "u","*", "e","+", "o",",", "ya","-", |
|---|
| 42 | "yu",".", "yo","/", "tu","/3^", "vvu","/3^'", "vva","/3^(", |
|---|
| 43 | "vvi","/3^*", "vve","/3^+", "vvo","/6", "kka","/6^", "gga","/7", |
|---|
| 44 | "kki","/7,", "kkya","/7-", "kkyu","/7.", "kkyo","/7^", "ggi","/7^,", |
|---|
| 45 | "ggya","/7^-", "ggyu","/7^.", "ggyo","/8", "kku","/8^", "ggu","/9", |
|---|
| 46 | "kke","/9^", "gge","/:", "kko","/:^", "ggo","/;", "ssa","/;^", |
|---|
| 47 | "zza","/<", "sshi","/<,", "ssha","/<-", "sshu","/<.", "ssho","/<^", |
|---|
| 48 | "jji","/<^,", "jja","/<^-", "jju","/<^.", "jjo","/=", "ssu","/=^", |
|---|
| 49 | "zzu","/>", "sse","/>^", "zze","/?", "sso","/?^", "zzo","/@", |
|---|
| 50 | "tta","/@^", "dda","/A", "cchi","/A,", "ccha","/A-", "cchu","/A.", |
|---|
| 51 | "ccho","/A^", "ddi","/A^,", "ddya","/A^-", "ddyu","/A^.", "ddyo","/B", |
|---|
| 52 | "ttsu","/B^", "ddu","/C", "tte","/C^", "dde","/D", "tto","/D^", |
|---|
| 53 | "ddo","/J", "hha","/J^", "bba","/J_", "ppa","/K", "hhi","/K,", |
|---|
| 54 | "hhya","/K-", "hhyu","/K.", "hhyo","/K^", "bbi","/K^,", "bbya","/K^-", |
|---|
| 55 | "bbyu","/K^.", "bbyo","/K_", "ppi","/K_,", "ppya","/K_-", |
|---|
| 56 | "ppyu","/K_.", "ppyo","/L", "ffu","/L'", "ffa","/L(", "ffi","/L*", |
|---|
| 57 | "ffe","/L+", "ffo","/L^", "bbu","/L_", "ppu","/M", "hhe","/M^", |
|---|
| 58 | "bbe","/M_", "ppe","/N", "hho","/N^", "bbo","/N_", "ppo","/T", |
|---|
| 59 | "yya","/U", "yyu","/V", "yyo","/W", "rra","/X", "rri","/X,", |
|---|
| 60 | "rrya","/X-", "rryu","/X.", "rryo","/Y", "rru","/Z", "rre","/[", |
|---|
| 61 | "rro","0", "^","1", "a","2", "i","3", "u","3^", "vu","3^'", |
|---|
| 62 | "va","3^(", "vi","3^*", "ve","3^+", "vo","4", "e","5", "o","6", |
|---|
| 63 | "ka","6^", "ga","7", "ki","7,", "kya","7-", "kyu","7.", "kyo","7^", |
|---|
| 64 | "gi","7^,", "gya","7^-", "gyu","7^.", "gyo","8", "ku","8^", "gu","9", |
|---|
| 65 | "ke","9^", "ge",":", "ko",":^", "go",";", "sa",";^", "za","<", |
|---|
| 66 | "shi","<,", "sha","<-", "shu","<.", "sho","<^", "ji","<^,", |
|---|
| 67 | "ja","<^-", "ju","<^.", "jo","=", "su","=^", "zu",">", "se",">^", |
|---|
| 68 | "ze","?", "so","?^", "zo","@", "ta","@^", "da","A", "chi","A,", |
|---|
| 69 | "cha","A-", "chu","A.", "cho","A^", "di","A^,", "dya","A^-", |
|---|
| 70 | "dyu","A^.", "dyo","B", "tsu","B^", "du","C", "te","C^", "de","D", |
|---|
| 71 | "to","D^", "do","E", "na","F", "ni","F,", "nya","F-", "nyu","F.", |
|---|
| 72 | "nyo","G", "nu","H", "ne","I", "no","J", "ha","J^", "ba","J_", |
|---|
| 73 | "pa","K", "hi","K,", "hya","K-", "hyu","K.", "hyo","K^", "bi","K^,", |
|---|
| 74 | "bya","K^-", "byu","K^.", "byo","K_", "pi","K_,", "pya","K_-", |
|---|
| 75 | "pyu","K_.", "pyo","L", "fu","L'", "fa","L(", "fi","L*", "fe","L+", |
|---|
| 76 | "fo","L^", "bu","L_", "pu","M", "he","M^", "be","M_", "pe","N", |
|---|
| 77 | "ho","N^", "bo","N_", "po","O", "ma","P", "mi","P,", "mya","P-", |
|---|
| 78 | "myu","P.", "myo","Q", "mu","R", "me","S", "mo","T", "ya","U", |
|---|
| 79 | "yu","V", "yo","W", "ra","X", "ri","X,", "rya","X-", "ryu","X.", |
|---|
| 80 | "ryo","Y", "ru","Z", "re","[", "ro","\\", "wa","]", "n", |
|---|
| 81 | "]1", "n'a", "]2", "n'i", "]3", "n'u", "]4", "n'e", "]5", "n'o", |
|---|
| 82 | "^", "\"","_", "(maru)", "", "" |
|---|
| 83 | }, k2rom_k_table[] = { |
|---|
| 84 | " ", " ", "!", ".", "\"", "(", "#", ")", "$", ",", "%", ".", "&", |
|---|
| 85 | "wo", "'", "a", "(", "i", ")", "u", "*", "e", "+", "o", ",", "ya", |
|---|
| 86 | "-", "yu", ".", "yo", "/", "tsu", "/3^", "vvu", "/3^'", "vva", "/3^(", |
|---|
| 87 | "vvi", "/3^*", "vve", "/3^+", "vvo", "/6", "kka", "/6^", "gga", "/7", |
|---|
| 88 | "kki", "/7,", "kkya", "/7-", "kkyu", "/7.", "kkyo", "/7^", "ggi", |
|---|
| 89 | "/7^,", "ggya", "/7^-", "ggyu", "/7^.", "ggyo", "/8", "kku", "/8^", |
|---|
| 90 | "ggu", "/9", "kke", "/9^", "gge", "/:", "kko", "/:^", "ggo", "/;", |
|---|
| 91 | "ssa", "/;^", "zza", "/<", "ssi", "/<,", "ssya", "/<-", "ssyu", "/<.", |
|---|
| 92 | "ssyo", "/<^", "zzi", "/<^,", "zzya", "/<^-", "zzyu", "/<^.", "zzyo", |
|---|
| 93 | "/=", "ssu", "/=^", "zzu", "/>", "sse", "/>^", "zze", "/?", "sso", |
|---|
| 94 | "/?^", "zzo", "/@", "tta", "/@^", "dda", "/A", "tti", "/A,", "ttya", |
|---|
| 95 | "/A-", "ttyu", "/A.", "ttyo", "/A^", "ddi", "/A^,", "ddya", "/A^-", |
|---|
| 96 | "ddyu", "/A^.", "ddyo", "/B", "ttu", "/B^", "ddu", "/C", "tte", "/C^", |
|---|
| 97 | "dde", "/D", "tto", "/D^", "ddo", "/J", "hha", "/J^", "bba", "/J_", |
|---|
| 98 | "ppa", "/K", "hhi", "/K,", "hhya", "/K-", "hhyu", "/K.", "hhyo", |
|---|
| 99 | "/K^", "bbi", "/K^,", "bbya", "/K^-", "bbyu", "/K^.", "bbyo", "/K_", |
|---|
| 100 | "ppi", "/K_,", "ppya", "/K_-", "ppyu", "/K_.", "ppyo", "/L", "hhu", |
|---|
| 101 | "/L'", "ffa", "/L(", "ffi", "/L*", "ffe", "/L+", "ffo", "/L^", "bbu", |
|---|
| 102 | "/L_", "ppu", "/M", "hhe", "/M^", "bbe", "/M_", "ppe", "/N", "hho", |
|---|
| 103 | "/N^", "bbo", "/N_", "ppo", "/T", "yya", "/U", "yyu", "/V", "yyo", |
|---|
| 104 | "/W", "rra", "/X", "rri", "/X,", "rrya", "/X-", "rryu", "/X.", "rryo", |
|---|
| 105 | "/Y", "rru", "/Z", "rre", "/[", "rro", "0", "^", "1", "a", "2", "i", |
|---|
| 106 | "3", "u", "3^", "vu", "3^'", "va", "3^(", "vi", "3^*", "ve", "3^+", |
|---|
| 107 | "vo", "4", "e", "5", "o", "6", "ka", "6^", "ga", "7", "ki", "7,", |
|---|
| 108 | "kya", "7-", "kyu", "7.", "kyo", "7^", "gi", "7^,", "gya", "7^-", |
|---|
| 109 | "gyu", "7^.", "gyo", "8", "ku", "8^", "gu", "9", "ke", "9^", "ge", |
|---|
| 110 | ":", "ko", ":^", "go", ";", "sa", ";^", "za", "<", "si", "<,", "sya", |
|---|
| 111 | "<-", "syu", "<.", "syo", "<^", "zi", "<^,", "zya", "<^-", "zyu", |
|---|
| 112 | "<^.", "zyo", "=", "su", "=^", "zu", ">", "se", ">^", "ze", "?", "so", |
|---|
| 113 | "?^", "zo", "@", "ta", "@^", "da", "A", "ti", "A,", "tya", "A-", |
|---|
| 114 | "tyu", "A.", "tyo", "A^", "di", "A^,", "dya", "A^-", "dyu", "A^.", |
|---|
| 115 | "dyo", "B", "tu", "B^", "du", "C", "te", "C^", "de", "D", "to", "D^", |
|---|
| 116 | "do", "E", "na", "F", "ni", "F,", "nya", "F-", "nyu", "F.", "nyo", |
|---|
| 117 | "G", "nu", "H", "ne", "I", "no", "J", "ha", "J^", "ba", "J_", "pa", |
|---|
| 118 | "K", "hi", "K,", "hya", "K-", "hyu", "K.", "hyo", "K^", "bi", "K^,", |
|---|
| 119 | "bya", "K^-", "byu", "K^.", "byo", "K_", "pi", "K_,", "pya", "K_-", |
|---|
| 120 | "pyu", "K_.", "pyo", "L", "hu", "L'", "fa", "L(", "fi", "L*", "fe", |
|---|
| 121 | "L+", "fo", "L^", "bu", "L_", "pu", "M", "he", "M^", "be", "M_", "pe", |
|---|
| 122 | "N", "ho", "N^", "bo", "N_", "po", "O", "ma", "P", "mi", "P,", "mya", |
|---|
| 123 | "P-", "myu", "P.", "myo", "Q", "mu", "R", "me", "S", "mo", "T", "ya", |
|---|
| 124 | "U", "yu", "V", "yo", "W", "ra", "X", "ri", "X,", "rya", "X-", "ryu", |
|---|
| 125 | "X.", "ryo", "Y", "ru", "Z", "re", "[", "ro", "\\", "wa", "]", "n", |
|---|
| 126 | "]1", "n'a", "]2", "n'i", "]3", "n'u", "]4", "n'e", "]5", "n'o", |
|---|
| 127 | "^", "\"", "_", "(maru)", "", ""}; |
|---|
| 128 | |
|---|
| 129 | |
|---|
| 130 | #define k2rom_buflen 10 |
|---|
| 131 | |
|---|
| 132 | static int |
|---|
| 133 | k2rom(c, n, type) |
|---|
| 134 | Character *c; |
|---|
| 135 | Character *n; |
|---|
| 136 | int type; |
|---|
| 137 | { |
|---|
| 138 | static int index_table[0x41]; |
|---|
| 139 | static int index_made=0; |
|---|
| 140 | static struct k2rom_tbl *k2rom_ptr; |
|---|
| 141 | struct k2rom_tbl *p; |
|---|
| 142 | int i, clen, ylen; |
|---|
| 143 | char buffer[k2rom_buflen]; |
|---|
| 144 | unsigned char c1; |
|---|
| 145 | int max_match, match_more; |
|---|
| 146 | char *max_romaji; |
|---|
| 147 | |
|---|
| 148 | if (index_made == 0) { |
|---|
| 149 | k2rom_ptr = (romaji_type == HEPBURN) ? k2rom_h_table : k2rom_k_table; |
|---|
| 150 | index_table[0] = 0; |
|---|
| 151 | for (p = k2rom_ptr, i = 0; *(p->kana) != '\0'; ++ p, ++ i) { |
|---|
| 152 | index_table[*(p->kana)-0x20+1] = i+1; |
|---|
| 153 | } |
|---|
| 154 | index_made = 1; |
|---|
| 155 | } |
|---|
| 156 | |
|---|
| 157 | buffer[k2rom_buflen] = '\0'; clen = k2rom_buflen; |
|---|
| 158 | for (i = 0; i < k2rom_buflen; ++ i) { |
|---|
| 159 | c1 = c[i].c1; |
|---|
| 160 | if ((0 < c1) && (c1 < 0x20)) |
|---|
| 161 | buffer[i] = ' '; |
|---|
| 162 | else if (0x60 < c1) |
|---|
| 163 | buffer[i] = ' '; |
|---|
| 164 | else |
|---|
| 165 | buffer[i] = c1; |
|---|
| 166 | |
|---|
| 167 | if (c1 == '\0') { |
|---|
| 168 | clen = i; |
|---|
| 169 | break; |
|---|
| 170 | } |
|---|
| 171 | } |
|---|
| 172 | |
|---|
| 173 | if (clen == 0) { |
|---|
| 174 | n[0].type=OTHER; |
|---|
| 175 | n[0].c1 = '\0'; |
|---|
| 176 | return 0; |
|---|
| 177 | } |
|---|
| 178 | |
|---|
| 179 | max_match = 0; |
|---|
| 180 | max_romaji = NULL; |
|---|
| 181 | match_more = 0; |
|---|
| 182 | for (i = index_table[buffer[0]-0x20]; |
|---|
| 183 | i < index_table[buffer[0]-0x20+1]; |
|---|
| 184 | ++ i) { |
|---|
| 185 | ylen = strlen(k2rom_ptr[i].kana); |
|---|
| 186 | if (clen >= ylen) { |
|---|
| 187 | if (max_match < ylen) { |
|---|
| 188 | if (strncmp(buffer, k2rom_ptr[i].kana, ylen) == 0) { |
|---|
| 189 | max_match = ylen; |
|---|
| 190 | max_romaji = k2rom_ptr[i].romaji; |
|---|
| 191 | } |
|---|
| 192 | } |
|---|
| 193 | } else { |
|---|
| 194 | if (match_more == 0) |
|---|
| 195 | if (strncmp(buffer, k2rom_ptr[i].kana, clen) == 0) |
|---|
| 196 | match_more = 1; |
|---|
| 197 | } |
|---|
| 198 | } |
|---|
| 199 | |
|---|
| 200 | for (i = 0; max_romaji[i] != '\0'; ++ i) { |
|---|
| 201 | n[i].type=type; |
|---|
| 202 | n[i].c1 = max_romaji[i]; |
|---|
| 203 | } |
|---|
| 204 | n[i].type=OTHER; |
|---|
| 205 | n[i].c1 = '\0'; |
|---|
| 206 | return (match_more == 0) ? max_match : -max_match; |
|---|
| 207 | } |
|---|
| 208 | |
|---|
| 209 | int |
|---|
| 210 | k2a(c, n) |
|---|
| 211 | Character *c; |
|---|
| 212 | Character *n; |
|---|
| 213 | { |
|---|
| 214 | return k2rom(c, n, ASCII); |
|---|
| 215 | } |
|---|
| 216 | |
|---|
| 217 | int |
|---|
| 218 | k2j(c, n) |
|---|
| 219 | Character *c; |
|---|
| 220 | Character *n; |
|---|
| 221 | { |
|---|
| 222 | return k2rom(c, n, JISROMAN); |
|---|
| 223 | } |
|---|
| 224 | |
|---|
| 225 | int |
|---|
| 226 | k2K(c, n) |
|---|
| 227 | Character *c; |
|---|
| 228 | Character *n; |
|---|
| 229 | { |
|---|
| 230 | int c1; |
|---|
| 231 | static unsigned char k2K_table[64][3] = { |
|---|
| 232 | "\241\241", "\241\243", "\241\326", "\241\327", "\241\242", "\241\245", "\245\362", "\245\241", |
|---|
| 233 | "\245\243", "\245\245", "\245\247", "\245\251", "\245\343", "\245\345", "\245\347", "\245\303", |
|---|
| 234 | "\241\274", "\245\242", "\245\244", "\245\246", "\245\250", "\245\252", "\245\253", "\245\255", |
|---|
| 235 | "\245\257", "\245\261", "\245\263", "\245\265", "\245\267", "\245\271", "\245\273", "\245\275", |
|---|
| 236 | "\245\277", "\245\301", "\245\304", "\245\306", "\245\310", "\245\312", "\245\313", "\245\314", |
|---|
| 237 | "\245\315", "\245\316", "\245\317", "\245\322", "\245\325", "\245\330", "\245\333", "\245\336", |
|---|
| 238 | "\245\337", "\245\340", "\245\341", "\245\342", "\245\344", "\245\346", "\245\350", "\245\351", |
|---|
| 239 | "\245\352", "\245\353", "\245\354", "\245\355", "\245\357", "\245\363", "\241\253", "\241\254" }; |
|---|
| 240 | static unsigned char k2K_dtable[64][3] = { |
|---|
| 241 | "", "", "", "", "", "", "", "", |
|---|
| 242 | "", "", "", "", "", "", "", "", |
|---|
| 243 | "", "", "", "\245\364", "", "", "\245\254", "\245\256", |
|---|
| 244 | "\245\260", "\245\262", "\245\264", "\245\266", "\245\270", "\245\272", "\245\274", "\245\276", |
|---|
| 245 | "\245\300", "\245\302", "\245\305", "\245\307", "\245\311", "", "", "", |
|---|
| 246 | "", "", "\245\320", "\245\323", "\245\326", "\245\331", "\245\334", "", |
|---|
| 247 | "", "", "", "", "", "", "", "", |
|---|
| 248 | "", "", "", "", "", "", "", "" }; |
|---|
| 249 | static unsigned char k2K_htable[64][3] = { |
|---|
| 250 | "", "", "", "", "", "", "", "", |
|---|
| 251 | "", "", "", "", "", "", "", "", |
|---|
| 252 | "", "", "", "", "", "", "", "", |
|---|
| 253 | "", "", "", "", "", "", "" , "", |
|---|
| 254 | "", "", "", "", "", "", "", "", |
|---|
| 255 | "", "", "\245\321", "\245\324", "\245\327", "\245\332", "\245\335", "", |
|---|
| 256 | "", "", "", "", "", "", "", "", |
|---|
| 257 | "", "", "", "", "", "", "", "" }; |
|---|
| 258 | |
|---|
| 259 | c1 = c -> c1; |
|---|
| 260 | if (c1 > 0x60) c1 = 0x20; |
|---|
| 261 | if (c[1].type==KATAKANA) { |
|---|
| 262 | if ((c[1].c1==0x5e) && (k2K_dtable[c1-0x20][0] != '\0')) { |
|---|
| 263 | n[0].type=JIS83; |
|---|
| 264 | n[0].c1 = k2K_dtable[c1-0x20][0]; |
|---|
| 265 | n[0].c2 = k2K_dtable[c1-0x20][1]; |
|---|
| 266 | n[1].type=OTHER; n[1].c1 = '\0'; |
|---|
| 267 | return 2; |
|---|
| 268 | } else if ((c[1].c1==0x5f) && (k2K_htable[c1-0x20][0] != '\0')) { |
|---|
| 269 | n[0].type=JIS83; |
|---|
| 270 | n[0].c1 = k2K_htable[c1-0x20][0]; |
|---|
| 271 | n[0].c2 = k2K_htable[c1-0x20][1]; |
|---|
| 272 | n[1].type=OTHER; n[1].c1 = '\0'; |
|---|
| 273 | return 2; |
|---|
| 274 | } else { |
|---|
| 275 | n[0].type=JIS83; |
|---|
| 276 | n[0].c1 = k2K_table[c1-0x20][0]; |
|---|
| 277 | n[0].c2 = k2K_table[c1-0x20][1]; |
|---|
| 278 | n[1].type=OTHER; n[1].c1 = '\0'; |
|---|
| 279 | return 1; |
|---|
| 280 | } |
|---|
| 281 | } else { |
|---|
| 282 | n[0].type=JIS83; |
|---|
| 283 | n[0].c1 = k2K_table[c1-0x20][0]; |
|---|
| 284 | n[0].c2 = k2K_table[c1-0x20][1]; |
|---|
| 285 | n[1].type=OTHER; n[1].c1 = '\0'; |
|---|
| 286 | if (k2K_dtable[c1-0x20][0] == '\0') |
|---|
| 287 | return 1; |
|---|
| 288 | else |
|---|
| 289 | return -1; |
|---|
| 290 | } |
|---|
| 291 | } |
|---|
| 292 | |
|---|
| 293 | int |
|---|
| 294 | k2H(c, n) |
|---|
| 295 | Character *c; |
|---|
| 296 | Character *n; |
|---|
| 297 | { |
|---|
| 298 | int c1; |
|---|
| 299 | static unsigned char k2H_table[64][3] = { |
|---|
| 300 | "\241\241", "\241\243", "\241\326", "\241\327", "\241\242", "\241\245", "\244\362", "\244\241", |
|---|
| 301 | "\244\243", "\244\245", "\244\247", "\244\251", "\244\343", "\244\345", "\244\347", "\244\303", |
|---|
| 302 | "\241\274", "\244\242", "\244\244", "\244\246", "\244\250", "\244\252", "\244\253", "\244\255", |
|---|
| 303 | "\244\257", "\244\261", "\244\263", "\244\265", "\244\267", "\244\271", "\244\273", "\244\275", |
|---|
| 304 | "\244\277", "\244\301", "\244\304", "\244\306", "\244\310", "\244\312", "\244\313", "\244\314", |
|---|
| 305 | "\244\315", "\244\316", "\244\317", "\244\322", "\244\325", "\244\330", "\244\333", "\244\336", |
|---|
| 306 | "\244\337", "\244\340", "\244\341", "\244\342", "\244\344", "\244\346", "\244\350", "\244\351", |
|---|
| 307 | "\244\352", "\244\353", "\244\354", "\244\355", "\244\357", "\244\363", "\241\253", "\241\254" }; |
|---|
| 308 | static unsigned char k2H_dtable[64][3] = { |
|---|
| 309 | "", "", "", "", "", "", "", "", |
|---|
| 310 | "", "", "", "", "", "", "", "", |
|---|
| 311 | "", "", "", "", "", "", "\244\254", "\244\256", |
|---|
| 312 | "\244\260", "\244\262", "\244\264", "\244\266", "\244\270", "\244\272", "\244\274", "\244\276", |
|---|
| 313 | "\244\300", "\244\302", "\244\305", "\244\307", "\244\311", "", "", "", |
|---|
| 314 | "", "", "\244\320", "\244\323", "\244\326", "\244\331", "\244\334", "", |
|---|
| 315 | "", "", "", "", "", "", "", "", |
|---|
| 316 | "", "", "", "", "", "", "", "" }; |
|---|
| 317 | static unsigned char k2H_htable[64][3] = { |
|---|
| 318 | "", "", "", "", "", "", "", "", |
|---|
| 319 | "", "", "", "", "", "", "", "", |
|---|
| 320 | "", "", "", "", "", "", "", "", |
|---|
| 321 | "", "", "", "", "", "", "" , "", |
|---|
| 322 | "", "", "", "", "", "", "", "", |
|---|
| 323 | "", "", "\244\321", "\244\324", "\244\327", "\244\332", "\244\335", "", |
|---|
| 324 | "", "", "", "", "", "", "", "", |
|---|
| 325 | "", "", "", "", "", "", "", "" }; |
|---|
| 326 | |
|---|
| 327 | c1 = c -> c1; |
|---|
| 328 | if (c1 > 0x60) c1 = 0x20; |
|---|
| 329 | if (c[1].type==KATAKANA) { |
|---|
| 330 | if ((c[1].c1==0x5e) && (k2H_dtable[c1-0x20][0] != '\0')) { |
|---|
| 331 | n[0].type=JIS83; |
|---|
| 332 | n[0].c1 = k2H_dtable[c1-0x20][0]; |
|---|
| 333 | n[0].c2 = k2H_dtable[c1-0x20][1]; |
|---|
| 334 | n[1].type=OTHER; n[1].c1 = '\0'; |
|---|
| 335 | return 2; |
|---|
| 336 | } else if ((c[1].c1==0x5f) && (k2H_htable[c1-0x20][0] != '\0')) { |
|---|
| 337 | n[0].type=JIS83; |
|---|
| 338 | n[0].c1 = k2H_htable[c1-0x20][0]; |
|---|
| 339 | n[0].c2 = k2H_htable[c1-0x20][1]; |
|---|
| 340 | n[1].type=OTHER; n[1].c1 = '\0'; |
|---|
| 341 | return 2; |
|---|
| 342 | } else { |
|---|
| 343 | n[0].type=JIS83; |
|---|
| 344 | n[0].c1 = k2H_table[c1-0x20][0]; |
|---|
| 345 | n[0].c2 = k2H_table[c1-0x20][1]; |
|---|
| 346 | n[1].type=OTHER; n[1].c1 = '\0'; |
|---|
| 347 | return 1; |
|---|
| 348 | } |
|---|
| 349 | } else { |
|---|
| 350 | n[0].type=JIS83; |
|---|
| 351 | n[0].c1 = k2H_table[c1-0x20][0]; |
|---|
| 352 | n[0].c2 = k2H_table[c1-0x20][1]; |
|---|
| 353 | n[1].type=OTHER; n[1].c1 = '\0'; |
|---|
| 354 | if (k2H_dtable[c1-0x20][0] == '\0') |
|---|
| 355 | return 1; |
|---|
| 356 | else |
|---|
| 357 | return -1; |
|---|
| 358 | } |
|---|
| 359 | } |
|---|