8 typedef struct convert_key convert_key;
16 static const convert_key s2j_table[] = {
17 {"mb","nb"}, {"mp","np"}, {"mv","nv"}, {"mm","nm"},
19 /* sindar:¥·¥ó¥À¡¼¥ë parantir:¥Ñ¥é¥ó¥Æ¥£¥¢ feanor:¥Õ¥§¥¢¥Î¡¼¥ë */
20 {"ar$","a-ru$"}, {"ir$","ia$"}, {"or$","o-ru$"},
21 {"ra","¥é"}, {"ri","¥ê"}, {"ru","¥ë"}, {"re","¥ì"}, {"ro","¥í"},
22 {"ir","ia"}, {"ur","ua"}, {"er","ea"}, {"ar","a¥ë"},
23 {"sha","¥·¥ã"}, {"shi","¥·"}, {"shu","¥·¥å"}, {"she","¥·¥§"}, {"sho","¥·¥ç"},
24 {"tha","¥µ"}, {"thi","¥·"}, {"thu","¥¹"}, {"the","¥»"}, {"tho","¥½"},
25 {"cha","¥Ï"}, {"chi","¥Ò"}, {"chu","¥Õ"}, {"che","¥Ø"}, {"cho","¥Û"},
26 {"dha","¥¶"}, {"dhi","¥¸"}, {"dhu","¥º"}, {"dhe","¥¼"}, {"dho","¥¾"},
27 {"ba","¥Ð"}, {"bi","¥Ó"}, {"bu","¥Ö"}, {"be","¥Ù"}, {"bo","¥Ü"},
28 {"ca","¥«"}, {"ci","¥"}, {"cu","¥¯"}, {"ce","¥±"}, {"co","¥³"},
29 {"da","¥À"}, {"di","¥Ç¥£"}, {"du","¥É¥¥"}, {"de","¥Ç"}, {"do","¥É"},
30 {"fa","¥Õ¥¡"}, {"fi","¥Õ¥£"}, {"fu","¥Õ"}, {"fe","¥Õ¥§"}, {"fo","¥Õ¥©"},
31 {"ga","¥¬"}, {"gi","¥®"}, {"gu","¥°"}, {"ge","¥²"}, {"go","¥´"},
32 {"ha","¥Ï"}, {"hi","¥Ò"}, {"hu","¥Õ"}, {"he","¥Ø"}, {"ho","¥Û"},
33 {"ja","¥¸¥ã"}, {"ji","¥¸"}, {"ju","¥¸¥å"}, {"je","¥¸¥§"}, {"jo","¥¸¥ç"},
34 {"ka","¥«"}, {"ki","¥"}, {"ku","¥¯"}, {"ke","¥±"}, {"ko","¥³"},
35 {"la","¥é"}, {"li","¥ê"}, {"lu","¥ë"}, {"le","¥ì"}, {"lo","¥í"},
36 {"ma","¥Þ"}, {"mi","¥ß"}, {"mu","¥à"}, {"me","¥á"}, {"mo","¥â"},
37 {"na","¥Ê"}, {"ni","¥Ë"}, {"nu","¥Ì"}, {"ne","¥Í"}, {"no","¥Î"},
38 {"pa","¥Ñ"}, {"pi","¥Ô"}, {"pu","¥×"}, {"pe","¥Ú"}, {"po","¥Ý"},
40 {"sa","¥µ"}, {"si","¥·"}, {"su","¥¹"}, {"se","¥»"}, {"so","¥½"},
41 {"ta","¥¿"}, {"ti","¥Æ¥£"}, {"tu","¥È¥¥"}, {"te","¥Æ"}, {"to","¥È"},
42 {"va","¥ô¥¡"}, {"vi","¥ô¥£"}, {"vu","¥ô"}, {"ve","¥ô¥§"}, {"vo","¥ô¥©"},
43 {"wa","¥ï"}, {"wi","¥¦¥£"}, {"wu","¥¦"}, {"we","¥¦¥§"}, {"wo","¥¦¥©"},
44 {"ya","¥ä"}, {"yu","¥æ"}, {"yo","¥è"},
45 {"za","¥¶"}, {"zi","¥¸"}, {"zu","¥º"}, {"ze","¥¼"}, {"zo","¥¾"},
46 {"dh","¥º"}, {"ch","¥Õ"}, {"th","¥¹"},
47 {"b","¥Ö"}, {"c","¥¯"}, {"d","¥É"}, {"f","¥Õ"}, {"g","¥°"},
48 {"h","¥Õ"}, {"j","¥¸¥å"}, {"k","¥¯"}, {"l","¥ë"}, {"m","¥à"},
49 {"n","¥ó"}, {"p","¥×"}, {"q","¥¯"}, {"r","¥ë"}, {"s","¥¹"},
50 {"t","¥È"}, {"v","¥ô"}, {"w","¥¦"}, {"y","¥¤"},
51 {"a","¥¢"}, {"i","¥¤"}, {"u","¥¦"}, {"e","¥¨"}, {"o","¥ª"},
56 /* ¥·¥ó¥À¥ê¥ó¤òÆüËܸì¤ÎÆɤߤËÊÑ´¹¤¹¤ë */
57 void sindarin_to_kana(char *kana, const char *sindarin)
62 sprintf(kana, "%s$", sindarin);
63 for (idx = 0; kana[idx]; idx++)
64 if (isupper(kana[idx])) kana[idx] = tolower(kana[idx]);
66 for (idx = 0; s2j_table[idx].key1 != NULL; idx++)
68 cptr pat1 = s2j_table[idx].key1;
69 cptr pat2 = s2j_table[idx].key2;
70 int len = strlen(pat1);
76 if (strncmp(src, pat1, len) == 0)
102 while (kana[idx] != '$') idx++;
108 /*ÆüËܸìÆ°»ì³èÍÑ (ÂǤġäÂǤäÆ,ÂǤÁ etc) */
110 #define CMPTAIL(y) strncmp(&in[l-strlen(y)],y,strlen(y))
112 /* ²¥¤ë,½³¤ë¡ä²¥¤ê,½³¤ë */
113 void jverb1( const char *in , char *out){
117 if( CMPTAIL("¤¹¤ë")==0) sprintf(&out[l-4],"¤·");else
118 if( CMPTAIL("¤¤¤ë")==0) sprintf(&out[l-4],"¤¤¤Æ");else
120 if( CMPTAIL("¤¨¤ë")==0) sprintf(&out[l-4],"¤¨");else
121 if( CMPTAIL("¤±¤ë")==0) sprintf(&out[l-4],"¤±");else
122 if( CMPTAIL("¤²¤ë")==0) sprintf(&out[l-4],"¤²");else
123 if( CMPTAIL("¤»¤ë")==0) sprintf(&out[l-4],"¤»");else
124 if( CMPTAIL("¤¼¤ë")==0) sprintf(&out[l-4],"¤¼");else
125 if( CMPTAIL("¤Æ¤ë")==0) sprintf(&out[l-4],"¤Æ");else
126 if( CMPTAIL("¤Ç¤ë")==0) sprintf(&out[l-4],"¤Ç");else
127 if( CMPTAIL("¤Í¤ë")==0) sprintf(&out[l-4],"¤Í");else
128 if( CMPTAIL("¤Ø¤ë")==0) sprintf(&out[l-4],"¤Ø");else
129 if( CMPTAIL("¤Ù¤ë")==0) sprintf(&out[l-4],"¤Ù");else
130 if( CMPTAIL("¤á¤ë")==0) sprintf(&out[l-4],"¤á");else
131 if( CMPTAIL("¤ì¤ë")==0) sprintf(&out[l-4],"¤ì");else
133 if( CMPTAIL("¤¦")==0) sprintf(&out[l-2],"¤¤");else
134 if( CMPTAIL("¤¯")==0) sprintf(&out[l-2],"¤");else
135 if( CMPTAIL("¤°")==0) sprintf(&out[l-2],"¤®");else
136 if( CMPTAIL("¤¹")==0) sprintf(&out[l-2],"¤·");else
137 if( CMPTAIL("¤º")==0) sprintf(&out[l-2],"¤¸");else
138 if( CMPTAIL("¤Ä")==0) sprintf(&out[l-2],"¤Á");else
139 if( CMPTAIL("¤Å")==0) sprintf(&out[l-2],"¤Â");else
140 if( CMPTAIL("¤Ì")==0) sprintf(&out[l-2],"¤Ë");else
141 if( CMPTAIL("¤Õ")==0) sprintf(&out[l-2],"¤Ò");else
142 if( CMPTAIL("¤Ö")==0) sprintf(&out[l-2],"¤Ó");else
143 if( CMPTAIL("¤à")==0) sprintf(&out[l-2],"¤ß");else
144 if( CMPTAIL("¤ë")==0) sprintf(&out[l-2],"¤ê");else
146 sprintf(&out[l],"¤½¤·¤Æ");}
148 /* ²¥¤ë,½³¤ë> ²¥¤Ã¤Æ½³¤ë */
149 void jverb2( const char *in , char *out){
153 if( CMPTAIL("¤¹¤ë")==0) sprintf(&out[l-4],"¤·¤Æ");else
154 if( CMPTAIL("¤¤¤ë")==0) sprintf(&out[l-4],"¤¤¤Æ");else
156 if( CMPTAIL("¤¨¤ë")==0) sprintf(&out[l-4],"¤¨¤Æ");else
157 if( CMPTAIL("¤±¤ë")==0) sprintf(&out[l-4],"¤±¤Æ");else
158 if( CMPTAIL("¤²¤ë")==0) sprintf(&out[l-4],"¤²¤Æ");else
159 if( CMPTAIL("¤»¤ë")==0) sprintf(&out[l-4],"¤»¤Æ");else
160 if( CMPTAIL("¤¼¤ë")==0) sprintf(&out[l-4],"¤¼¤Æ");else
161 if( CMPTAIL("¤Æ¤ë")==0) sprintf(&out[l-4],"¤Æ¤Ã¤Æ");else
162 if( CMPTAIL("¤Ç¤ë")==0) sprintf(&out[l-4],"¤Ç¤Æ");else
163 if( CMPTAIL("¤Í¤ë")==0) sprintf(&out[l-4],"¤Í¤Æ");else
164 if( CMPTAIL("¤Ø¤ë")==0) sprintf(&out[l-4],"¤Ø¤Æ");else
165 if( CMPTAIL("¤Ù¤ë")==0) sprintf(&out[l-4],"¤Ù¤Æ");else
166 if( CMPTAIL("¤á¤ë")==0) sprintf(&out[l-4],"¤á¤Æ");else
167 if( CMPTAIL("¤ì¤ë")==0) sprintf(&out[l-4],"¤ì¤Æ");else
169 if( CMPTAIL("¤¦")==0) sprintf(&out[l-2],"¤Ã¤Æ");else
170 if( CMPTAIL("¤¯")==0) sprintf(&out[l-2],"¤¤¤Æ");else
171 if( CMPTAIL("¤°")==0) sprintf(&out[l-2],"¤¤¤Ç");else
172 if( CMPTAIL("¤¹")==0) sprintf(&out[l-2],"¤·¤Æ");else
173 if( CMPTAIL("¤º")==0) sprintf(&out[l-2],"¤¸¤Æ");else
174 if( CMPTAIL("¤Ä")==0) sprintf(&out[l-2],"¤Ã¤Æ");else
175 if( CMPTAIL("¤Å")==0) sprintf(&out[l-2],"¤Ã¤Æ");else
176 if( CMPTAIL("¤Ì")==0) sprintf(&out[l-2],"¤Í¤Æ");else
177 if( CMPTAIL("¤Õ")==0) sprintf(&out[l-2],"¤Ø¤Æ");else
178 if( CMPTAIL("¤Ö")==0) sprintf(&out[l-2],"¤ó¤Ç");else
179 if( CMPTAIL("¤à")==0) sprintf(&out[l-2],"¤ó¤Ç");else
180 if( CMPTAIL("¤ë")==0) sprintf(&out[l-2],"¤Ã¤Æ");else
181 sprintf(&out[l],"¤³¤È¤Ë¤è¤ê");}
183 /* ²¥¤ë,½³¤ë > ²¥¤Ã¤¿¤ê½³¤Ã¤¿¤ê */
184 void jverb3( const char *in , char *out){
188 if( CMPTAIL("¤¹¤ë")==0) sprintf(&out[l-4],"¤·¤¿");else
189 if( CMPTAIL("¤¤¤ë")==0) sprintf(&out[l-4],"¤¤¤¿");else
191 if( CMPTAIL("¤¨¤ë")==0) sprintf(&out[l-4],"¤¨¤¿");else
192 if( CMPTAIL("¤±¤ë")==0) sprintf(&out[l-4],"¤±¤¿");else
193 if( CMPTAIL("¤²¤ë")==0) sprintf(&out[l-4],"¤²¤¿");else
194 if( CMPTAIL("¤»¤ë")==0) sprintf(&out[l-4],"¤»¤¿");else
195 if( CMPTAIL("¤¼¤ë")==0) sprintf(&out[l-4],"¤¼¤¿");else
196 if( CMPTAIL("¤Æ¤ë")==0) sprintf(&out[l-4],"¤Æ¤Ã¤¿");else
197 if( CMPTAIL("¤Ç¤ë")==0) sprintf(&out[l-4],"¤Ç¤¿");else
198 if( CMPTAIL("¤Í¤ë")==0) sprintf(&out[l-4],"¤Í¤¿");else
199 if( CMPTAIL("¤Ø¤ë")==0) sprintf(&out[l-4],"¤Ø¤¿");else
200 if( CMPTAIL("¤Ù¤ë")==0) sprintf(&out[l-4],"¤Ù¤¿");else
201 if( CMPTAIL("¤á¤ë")==0) sprintf(&out[l-4],"¤á¤¿");else
202 if( CMPTAIL("¤ì¤ë")==0) sprintf(&out[l-4],"¤ì¤¿");else
204 if( CMPTAIL("¤¦")==0) sprintf(&out[l-2],"¤Ã¤¿");else
205 if( CMPTAIL("¤¯")==0) sprintf(&out[l-2],"¤¤¤¿");else
206 if( CMPTAIL("¤°")==0) sprintf(&out[l-2],"¤¤¤À");else
207 if( CMPTAIL("¤¹")==0) sprintf(&out[l-2],"¤·¤¿");else
208 if( CMPTAIL("¤º")==0) sprintf(&out[l-2],"¤¸¤¿");else
209 if( CMPTAIL("¤Ä")==0) sprintf(&out[l-2],"¤Ã¤¿");else
210 if( CMPTAIL("¤Å")==0) sprintf(&out[l-2],"¤Ã¤¿");else
211 if( CMPTAIL("¤Ì")==0) sprintf(&out[l-2],"¤Í¤¿");else
212 if( CMPTAIL("¤Õ")==0) sprintf(&out[l-2],"¤Ø¤¿");else
213 if( CMPTAIL("¤Ö")==0) sprintf(&out[l-2],"¤ó¤À");else
214 if( CMPTAIL("¤à")==0) sprintf(&out[l-2],"¤ó¤À");else
215 if( CMPTAIL("¤ë")==0) sprintf(&out[l-2],"¤Ã¤¿");else
216 sprintf(&out[l],"¤³¤È¤ä");}
219 void jverb( const char *in , char *out , int flag){
221 case JVERB_AND:jverb1(in , out);break;
222 case JVERB_TO :jverb2(in , out);break;
223 case JVERB_OR :jverb3(in , out);break;
229 * Convert SJIS string to EUC string
231 void sjis2euc(char *str)
234 unsigned char c1, c2;
237 int len = strlen(str);
239 C_MAKE(tmp, len+1, byte);
241 for (i = 0; i < len; i++)
250 c1 = c1 * 2 - (c1 >= 0xe0 ? 0xe0 : 0x60);
255 c1 = c1 * 2 - (c1 >= 0xe0 ? 0xe1 : 0x61);
256 c2 += 0x60 + (c2 < 0x7f);
265 strcpy(str, (char *)tmp);
267 C_KILL(tmp, len+1, byte);
272 * Convert EUC string to SJIS string
274 void euc2sjis(char *str)
277 unsigned char c1, c2;
280 int len = strlen(str);
282 C_MAKE(tmp, len+1, byte);
284 for (i = 0; i < len; i++)
293 c1 = (c1 >> 1) + (c1 < 0xdf ? 0x31 : 0x71);
294 c2 -= 0x60 + (c2 < 0xe0);
298 c1 = (c1 >> 1) + (c1 < 0xdf ? 0x30 : 0x70);
309 strcpy(str, (char *)tmp);
311 C_KILL(tmp, len+1, byte);
316 * str¤ò´Ä¶¤Ë¹ç¤Ã¤¿Ê¸»ú¥³¡¼¥É¤ËÊÑ´¹¤·¡¢ÊÑ´¹Á°¤Îʸ»ú¥³¡¼¥É¤òÊÖ¤¹¡£
317 * str¤ÎŤµ¤ËÀ©¸Â¤Ï¤Ê¤¤¡£
320 * 1: ASCII (Never known to be ASCII in this function.)
324 byte codeconv(char *str)
329 for (i = 0; str[i]; i++)
338 if (!(c1 & 0x80)) continue;
344 if (((0xa1 <= c1 && c1 <= 0xdf) || (0xfd <= c1 && c1 <= 0xfe)) &&
345 (0xa1 <= c2 && c2 <= 0xfe))
347 /* Only EUC is allowed */
362 else if (((0x81 <= c1 && c1 <= 0x9f) &&
363 ((0x40 <= c2 && c2 <= 0x7e) || (0x80 <= c2 && c2 <= 0xfc))) ||
364 ((0xe0 <= c1 && c1 <= 0xfc) &&
365 (0x40 <= c2 && c2 <= 0x7e)))
367 /* Only SJIS is allowed */
402 /* Return kanji code */
406 /* ʸ»úÎós¤Îx¥Ð¥¤¥ÈÌܤ¬´Á»ú¤Î1¥Ð¥¤¥ÈÌܤ«¤É¤¦¤«È½Äꤹ¤ë */
407 bool iskanji2(cptr s, int x)
411 for (i = 0; i < x; i++)
413 if (iskanji(s[i])) i++;
415 if ((x == i) && iskanji(s[x])) return TRUE;