+++ /dev/null
-/* File: japanese.c */
-
-
-#include "angband.h"
-
-#ifdef JP
-
-/*ÆüËܸìÆ°»ì³èÍÑ (ÂǤġäÂǤäÆ,ÂǤÁ etc) */
-
-#define CMPTAIL(y) strncmp(&in[l-strlen(y)],y,strlen(y))
-
-/* ²¥¤ë,½³¤ë¡ä²¥¤ê,½³¤ë */
-void jverb1( const char *in , char *out){
-int l=strlen(in);
-strcpy(out,in);
-
-if( CMPTAIL("¤¹¤ë")==0) sprintf(&out[l-4],"¤·");else
-if( CMPTAIL("¤¤¤ë")==0) sprintf(&out[l-4],"¤¤¤Æ");else
-
-if( CMPTAIL("¤¨¤ë")==0) sprintf(&out[l-4],"¤¨");else
-if( CMPTAIL("¤±¤ë")==0) sprintf(&out[l-4],"¤±");else
-if( CMPTAIL("¤²¤ë")==0) sprintf(&out[l-4],"¤²");else
-if( CMPTAIL("¤»¤ë")==0) sprintf(&out[l-4],"¤»");else
-if( CMPTAIL("¤¼¤ë")==0) sprintf(&out[l-4],"¤¼");else
-if( CMPTAIL("¤Æ¤ë")==0) sprintf(&out[l-4],"¤Æ");else
-if( CMPTAIL("¤Ç¤ë")==0) sprintf(&out[l-4],"¤Ç");else
-if( CMPTAIL("¤Í¤ë")==0) sprintf(&out[l-4],"¤Í");else
-if( CMPTAIL("¤Ø¤ë")==0) sprintf(&out[l-4],"¤Ø");else
-if( CMPTAIL("¤Ù¤ë")==0) sprintf(&out[l-4],"¤Ù");else
-if( CMPTAIL("¤á¤ë")==0) sprintf(&out[l-4],"¤á");else
-if( CMPTAIL("¤ì¤ë")==0) sprintf(&out[l-4],"¤ì");else
-
-if( CMPTAIL("¤¦")==0) sprintf(&out[l-2],"¤¤");else
-if( CMPTAIL("¤¯")==0) sprintf(&out[l-2],"¤");else
-if( CMPTAIL("¤°")==0) sprintf(&out[l-2],"¤®");else
-if( CMPTAIL("¤¹")==0) sprintf(&out[l-2],"¤·");else
-if( CMPTAIL("¤º")==0) sprintf(&out[l-2],"¤¸");else
-if( CMPTAIL("¤Ä")==0) sprintf(&out[l-2],"¤Á");else
-if( CMPTAIL("¤Å")==0) sprintf(&out[l-2],"¤Â");else
-if( CMPTAIL("¤Ì")==0) sprintf(&out[l-2],"¤Ë");else
-if( CMPTAIL("¤Õ")==0) sprintf(&out[l-2],"¤Ò");else
-if( CMPTAIL("¤Ö")==0) sprintf(&out[l-2],"¤Ó");else
-if( CMPTAIL("¤à")==0) sprintf(&out[l-2],"¤ß");else
-if( CMPTAIL("¤ë")==0) sprintf(&out[l-2],"¤ê");else
-
- sprintf(&out[l],"¤½¤·¤Æ");}
-
-/* ²¥¤ë,½³¤ë> ²¥¤Ã¤Æ½³¤ë */
-void jverb2( const char *in , char *out){
-int l=strlen(in);
-strcpy(out,in);
-
-if( CMPTAIL("¤¹¤ë")==0) sprintf(&out[l-4],"¤·¤Æ");else
-if( CMPTAIL("¤¤¤ë")==0) sprintf(&out[l-4],"¤¤¤Æ");else
-
-if( CMPTAIL("¤¨¤ë")==0) sprintf(&out[l-4],"¤¨¤Æ");else
-if( CMPTAIL("¤±¤ë")==0) sprintf(&out[l-4],"¤±¤Æ");else
-if( CMPTAIL("¤²¤ë")==0) sprintf(&out[l-4],"¤²¤Æ");else
-if( CMPTAIL("¤»¤ë")==0) sprintf(&out[l-4],"¤»¤Æ");else
-if( CMPTAIL("¤¼¤ë")==0) sprintf(&out[l-4],"¤¼¤Æ");else
-if( CMPTAIL("¤Æ¤ë")==0) sprintf(&out[l-4],"¤Æ¤Ã¤Æ");else
-if( CMPTAIL("¤Ç¤ë")==0) sprintf(&out[l-4],"¤Ç¤Æ");else
-if( CMPTAIL("¤Í¤ë")==0) sprintf(&out[l-4],"¤Í¤Æ");else
-if( CMPTAIL("¤Ø¤ë")==0) sprintf(&out[l-4],"¤Ø¤Æ");else
-if( CMPTAIL("¤Ù¤ë")==0) sprintf(&out[l-4],"¤Ù¤Æ");else
-if( CMPTAIL("¤á¤ë")==0) sprintf(&out[l-4],"¤á¤Æ");else
-if( CMPTAIL("¤ì¤ë")==0) sprintf(&out[l-4],"¤ì¤Æ");else
-
-if( CMPTAIL("¤¦")==0) sprintf(&out[l-2],"¤Ã¤Æ");else
-if( CMPTAIL("¤¯")==0) sprintf(&out[l-2],"¤¤¤Æ");else
-if( CMPTAIL("¤°")==0) sprintf(&out[l-2],"¤¤¤Ç");else
-if( CMPTAIL("¤¹")==0) sprintf(&out[l-2],"¤·¤Æ");else
-if( CMPTAIL("¤º")==0) sprintf(&out[l-2],"¤¸¤Æ");else
-if( CMPTAIL("¤Ä")==0) sprintf(&out[l-2],"¤Ã¤Æ");else
-if( CMPTAIL("¤Å")==0) sprintf(&out[l-2],"¤Ã¤Æ");else
-if( CMPTAIL("¤Ì")==0) sprintf(&out[l-2],"¤Í¤Æ");else
-if( CMPTAIL("¤Õ")==0) sprintf(&out[l-2],"¤Ø¤Æ");else
-if( CMPTAIL("¤Ö")==0) sprintf(&out[l-2],"¤ó¤Ç");else
-if( CMPTAIL("¤à")==0) sprintf(&out[l-2],"¤ó¤Ç");else
-if( CMPTAIL("¤ë")==0) sprintf(&out[l-2],"¤Ã¤Æ");else
- sprintf(&out[l],"¤³¤È¤Ë¤è¤ê");}
-
-/* ²¥¤ë,½³¤ë > ²¥¤Ã¤¿¤ê½³¤Ã¤¿¤ê */
-void jverb3( const char *in , char *out){
-int l=strlen(in);
-strcpy(out,in);
-
-if( CMPTAIL("¤¹¤ë")==0) sprintf(&out[l-4],"¤·¤¿");else
-if( CMPTAIL("¤¤¤ë")==0) sprintf(&out[l-4],"¤¤¤¿");else
-
-if( CMPTAIL("¤¨¤ë")==0) sprintf(&out[l-4],"¤¨¤¿");else
-if( CMPTAIL("¤±¤ë")==0) sprintf(&out[l-4],"¤±¤¿");else
-if( CMPTAIL("¤²¤ë")==0) sprintf(&out[l-4],"¤²¤¿");else
-if( CMPTAIL("¤»¤ë")==0) sprintf(&out[l-4],"¤»¤¿");else
-if( CMPTAIL("¤¼¤ë")==0) sprintf(&out[l-4],"¤¼¤¿");else
-if( CMPTAIL("¤Æ¤ë")==0) sprintf(&out[l-4],"¤Æ¤Ã¤¿");else
-if( CMPTAIL("¤Ç¤ë")==0) sprintf(&out[l-4],"¤Ç¤¿");else
-if( CMPTAIL("¤Í¤ë")==0) sprintf(&out[l-4],"¤Í¤¿");else
-if( CMPTAIL("¤Ø¤ë")==0) sprintf(&out[l-4],"¤Ø¤¿");else
-if( CMPTAIL("¤Ù¤ë")==0) sprintf(&out[l-4],"¤Ù¤¿");else
-if( CMPTAIL("¤á¤ë")==0) sprintf(&out[l-4],"¤á¤¿");else
-if( CMPTAIL("¤ì¤ë")==0) sprintf(&out[l-4],"¤ì¤¿");else
-
-if( CMPTAIL("¤¦")==0) sprintf(&out[l-2],"¤Ã¤¿");else
-if( CMPTAIL("¤¯")==0) sprintf(&out[l-2],"¤¤¤¿");else
-if( CMPTAIL("¤°")==0) sprintf(&out[l-2],"¤¤¤À");else
-if( CMPTAIL("¤¹")==0) sprintf(&out[l-2],"¤·¤¿");else
-if( CMPTAIL("¤º")==0) sprintf(&out[l-2],"¤¸¤¿");else
-if( CMPTAIL("¤Ä")==0) sprintf(&out[l-2],"¤Ã¤¿");else
-if( CMPTAIL("¤Å")==0) sprintf(&out[l-2],"¤Ã¤¿");else
-if( CMPTAIL("¤Ì")==0) sprintf(&out[l-2],"¤Í¤¿");else
-if( CMPTAIL("¤Õ")==0) sprintf(&out[l-2],"¤Ø¤¿");else
-if( CMPTAIL("¤Ö")==0) sprintf(&out[l-2],"¤ó¤À");else
-if( CMPTAIL("¤à")==0) sprintf(&out[l-2],"¤ó¤À");else
-if( CMPTAIL("¤ë")==0) sprintf(&out[l-2],"¤Ã¤¿");else
- sprintf(&out[l],"¤³¤È¤ä");}
-
-
-void jverb( const char *in , char *out , int flag){
- switch (flag){
- case JVERB_AND:jverb1(in , out);break;
- case JVERB_TO :jverb2(in , out);break;
- case JVERB_OR :jverb3(in , out);break;
- }
-}
-
-
-/*
- * Convert SJIS string to EUC string
- */
-void sjis2euc(char *str)
-{
- int i;
- unsigned char c1, c2;
- unsigned char *tmp;
-
- int len = strlen(str);
-
- C_MAKE(tmp, len+1, byte);
-
- for (i = 0; i < len; 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[len] = 0;
- strcpy(str, (char *)tmp);
-
- C_KILL(tmp, len+1, byte);
-}
-
-
-/*
- * Convert EUC string to SJIS string
- */
-void euc2sjis(char *str)
-{
- int i;
- unsigned char c1, c2;
- unsigned char *tmp;
-
- int len = strlen(str);
-
- C_MAKE(tmp, len+1, byte);
-
- for (i = 0; i < len; 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[len] = 0;
- strcpy(str, (char *)tmp);
-
- C_KILL(tmp, len+1, byte);
-}
-
-
-/*
- * str¤ò´Ä¶¤Ë¹ç¤Ã¤¿Ê¸»ú¥³¡¼¥É¤ËÊÑ´¹¤·¡¢ÊÑ´¹Á°¤Îʸ»ú¥³¡¼¥É¤òÊÖ¤¹¡£
- * str¤ÎŤµ¤ËÀ©¸Â¤Ï¤Ê¤¤¡£
- *
- * 0: Unknown
- * 1: ASCII (Never known to be ASCII in this function.)
- * 2: EUC
- * 3: SJIS
- */
-byte codeconv(char *str)
-{
- byte code = 0;
- int i;
-
- for (i = 0; str[i]; i++)
- {
- unsigned char c1;
- unsigned char c2;
-
- /* First byte */
- c1 = str[i];
-
- /* ASCII? */
- if (!(c1 & 0x80)) continue;
-
- /* Second byte */
- i++;
- c2 = str[i];
-
- if (((0xa1 <= c1 && c1 <= 0xdf) || (0xfd <= c1 && c1 <= 0xfe)) &&
- (0xa1 <= c2 && c2 <= 0xfe))
- {
- /* Only EUC is allowed */
- if (!code)
- {
- /* EUC */
- code = 2;
- }
-
- /* Broken string? */
- else if (code != 2)
- {
- /* No conversion */
- return 0;
- }
- }
-
- else if (((0x81 <= c1 && c1 <= 0x9f) &&
- ((0x40 <= c2 && c2 <= 0x7e) || (0x80 <= c2 && c2 <= 0xfc))) ||
- ((0xe0 <= c1 && c1 <= 0xfc) &&
- (0x40 <= c2 && c2 <= 0x7e)))
- {
- /* Only SJIS is allowed */
- if (!code)
- {
- /* SJIS */
- code = 3;
- }
-
- /* Broken string? */
- else if (code != 3)
- {
- /* No conversion */
- return 0;
- }
- }
- }
-
-
- switch (code)
- {
-#ifdef EUC
- case 3:
- /* SJIS -> EUC */
- sjis2euc(str);
- break;
-#endif
-
-#ifdef SJIS
- case 2:
- /* EUC -> SJIS */
- euc2sjis(str);
-
- break;
-#endif
- }
-
- /* Return kanji code */
- return code;
-}
-
-/* ʸ»úÎós¤Îx¥Ð¥¤¥ÈÌܤ¬´Á»ú¤Î1¥Ð¥¤¥ÈÌܤ«¤É¤¦¤«È½Äꤹ¤ë */
-bool iskanji2(cptr s, int x)
-{
- int i;
-
- for (i = 0; i < x; i++)
- {
- if (iskanji(s[i])) i++;
- }
- if ((x == i) && iskanji(s[x])) return TRUE;
-
- return FALSE;
-}
-
-#endif /* JP */
-