extern void jverb( const char *in , char *out , int flag);
extern char* strstr_j(cptr str1, cptr str2);
extern size_t mb_strlcpy(char *dst, const char *src, size_t size);
+extern void codeconv(char *str);
#endif
#ifdef WORLD_SCORE
return n;
}
+/*
+ * str¤ò´Ä¶¤Ë¹ç¤Ã¤¿Ê¸»ú¥³¡¼¥É¤ËÊÑ´¹¤¹¤ë¡£
+ * str¤ÎŤµ¤ËÀ©¸Â¤Ï¤Ê¤¤¡£
+ */
+void codeconv(char *str)
+{
+ int i;
+ int kanji = 0, iseuc = 1;
+ int len;
+ unsigned char c1, c2;
+ unsigned char *tmp;
+
+ /* ´Á»ú¤¬Â¸ºß¤·¡¢¤½¤Î´Á»ú¥³¡¼¥É¤¬EUC¤«¤É¤¦¤«Ä´¤Ù¤ë¡£*/
+ for (i = 0; str[i]; i++)
+ {
+ c1 = str[i];
+ if (c1 & 0x80) kanji = 1;
+ if ( c1>=0x80 && (c1 < 0xa1 || c1 > 0xfe)) iseuc = 0;
+ }
+
+ /* str¤ÎŤµ+1(tmp³ÎÊÝÍÑ) */
+ len = i + 1;
+
+#ifdef EUC
+ if (kanji && !iseuc) /* SJIS -> EUC */
+ {
+ C_MAKE(tmp, len, byte);
+
+ for (i = 0; str[i]; i++)
+ {
+ c1 = str[i];
+ if (c1 & 0x80)
+ {
+ i++;
+ c2 = str[i];
+ if (c2 >= 0x9f)
+ {
+ c1 = c1 * 2 - (c1 >= 0xe0 ? 0xe0 : 0x60);
+ c2 += 2;
+ }
+ else
+ {
+ c1 = c1 * 2 - (c1 >= 0xe0 ? 0xe1 : 0x61);
+ c2 += 0x60 + (c2 < 0x7f);
+ }
+ tmp[i - 1] = c1;
+ tmp[i] = c2;
+ }
+ else
+ tmp[i] = c1;
+ }
+ tmp[i] = '\0';
+ strcpy(str, tmp);
+
+ C_KILL(tmp, len, byte);
+ }
+#endif
+
+#ifdef SJIS
+ if (kanji && iseuc) /* EUC -> SJIS */
+ {
+ C_MAKE(tmp, len, byte);
+
+ for (i = 0; str[i]; i++)
+ {
+ c1 = str[i];
+ if (c1 & 0x80)
+ {
+ i++;
+ c2 = str[i];
+ if (c1 % 2)
+ {
+ c1 = (c1 >> 1) + (c1 < 0xdf ? 0x31 : 0x71);
+ c2 -= 0x60 + (c2 < 0xe0);
+ }
+ else
+ {
+ c1 = (c1 >> 1) + (c1 < 0xdf ? 0x30 : 0x70);
+ c2 -= 2;
+ }
+ tmp[i - 1] = c1;
+ tmp[i] = c2;
+ }
+ else
+ tmp[i] = c1;
+ }
+ tmp[i] = '\0';
+ strcpy(str, tmp);
+
+ C_KILL(tmp, len, byte);
+ }
+#endif
+}
+
#endif /* JP */
{
int i;
-#ifdef JP
- int kanji, iseuc,l;
- unsigned char c1,c2;
-#endif
/* Read the string */
for (i = 0; TRUE; i++)
{
/* Terminate */
str[max-1] = '\0';
#ifdef JP
- kanji = 0;
- iseuc = 1;
- l=strlen(str);
- for (i = 0; i < l; i++) {
- c1 = str[i];
- if (c1 & 0x80) kanji = 1;
- if ( c1>=0x80 && (c1 < 0xa1 || c1 > 0xfe)) iseuc = 0;
- }
-#ifdef EUC
- if (kanji && !iseuc) {
- unsigned char tmp[256];
- for (i = 0; i < l; i++) {
- c1 = str[i];
- if (c1 & 0x80) {
- i++;
- c2 = str[i];
- if (c2 >= 0x9f) {
- c1 = c1 * 2 - (c1 >= 0xe0 ? 0xe0 : 0x60);
- c2 += 2;
- } else {
- c1 = c1 * 2 - (c1 >= 0xe0 ? 0xe1 : 0x61);
- c2 += 0x60 + (c2 < 0x7f);
- }
- tmp[i - 1] = c1;
- tmp[i] = c2;
- } else
- tmp[i] = c1;
- }
- tmp[l] = 0;
- strcpy(str, (char *)tmp);
- }
-#endif
-
-#ifdef SJIS
- if (kanji && iseuc) {
- unsigned char tmp[256];
- for (i = 0; i < l; i++) {
- c1 = str[i];
- if (c1 & 0x80) {
- i++;
- c2 = str[i];
- if (c1 % 2) {
- c1 = (c1 >> 1) + (c1 < 0xdf ? 0x31 : 0x71);
- c2 -= 0x60 + (c2 < 0xe0);
- } else {
- c1 = (c1 >> 1) + (c1 < 0xdf ? 0x30 : 0x70);
- c2 -= 2;
- }
- tmp[i - 1] = c1;
- tmp[i] = c2;
- } else
- tmp[i] = c1;
- }
- tmp[l] = 0;
- strcpy(str, tmp);
- }
-#endif
-
+ codeconv(str);
#endif
}