X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fjapanese.c;h=a3c0cf0df04a75b9324faada6719164e9d5fb895;hb=39e40bc486940f16686fe25ac451fd5ba0c45207;hp=ae058d980d7d67259eabe2a4414e66d19f97abfa;hpb=d70ddc843f8ff8688bc398fabb9360e6b0e23944;p=hengband%2Fhengband.git diff --git a/src/japanese.c b/src/japanese.c index ae058d980..a3c0cf0df 100644 --- a/src/japanese.c +++ b/src/japanese.c @@ -1,5 +1,8 @@ -/* File: japanese.c */ - +/*! + * @file japanese.c + * @brief 日本語処理関数 + * @date 2014/07/07 + */ #include "angband.h" @@ -53,7 +56,13 @@ static const convert_key s2j_table[] = { {NULL,NULL} }; -/* シンダリンを日本語の読みに変換する */ +/*! + * @brief シンダリンを日本語の読みに変換する + * @param kana 変換後の日本語文字列ポインタ + * @param sindarin 変換前のシンダリン文字列ポインタ + * @return なし + * @details + */ void sindarin_to_kana(char *kana, const char *sindarin) { char buf[256]; @@ -61,7 +70,7 @@ void sindarin_to_kana(char *kana, const char *sindarin) sprintf(kana, "%s$", sindarin); for (idx = 0; kana[idx]; idx++) - if (isupper(kana[idx])) kana[idx] = tolower(kana[idx]); + if (isupper(kana[idx])) kana[idx] = (char)tolower(kana[idx]); for (idx = 0; s2j_table[idx].key1 != NULL; idx++) { @@ -105,11 +114,10 @@ void sindarin_to_kana(char *kana, const char *sindarin) } -/*日本語動詞活用 (打つ>打って,打ち etc) */ -/* JVERB_AND: 殴る,蹴る > 殴り,蹴る */ -/* JVERB_TO: 殴る,蹴る > 殴って蹴る */ -/* JVERB_OR: 殴る,蹴る > 殴ったり蹴ったり */ - +/*! 日本語動詞活用 (打つ>打って,打ち etc) + * JVERB_AND: 殴る,蹴る > 殴り,蹴る + * JVERB_TO: 殴る,蹴る > 殴って蹴る + * JVERB_OR: 殴る,蹴る > 殴ったり蹴ったり */ static const struct jverb_table_t { const char* from; const char* to[3]; @@ -145,7 +153,15 @@ static const struct jverb_table_t { { NULL, {"そして", "ことにより", "ことや"}}, }; -void jverb(const char *in , char *out , int flag) +/*! + * @brief jverb_table_tに従って動詞を活用する + * @param in 変換元文字列ポインタ + * @param out 変換先文字列ポインタ + * @param flag 変換種類を指定(JVERB_AND/JVERB_TO/JVERB_OR) + * @return なし + * @details + */ +void jverb(const char *in, char *out, int flag) { const struct jverb_table_t * p; int in_len = strlen(in); @@ -164,9 +180,11 @@ void jverb(const char *in , char *out , int flag) strcpy(&out[in_len], p->to[flag - 1]); } - -/* - * Convert SJIS string to EUC string +/*! + * @brief 文字コードをSJISからEUCに変換する / Convert SJIS string to EUC string + * @param str 変換する文字列のポインタ + * @return なし + * @details */ void sjis2euc(char *str) { @@ -208,8 +226,11 @@ void sjis2euc(char *str) } -/* - * Convert EUC string to SJIS string +/*! + * @brief 文字コードをEUCからSJISに変換する / Convert EUC string to SJIS string + * @param str 変換する文字列のポインタ + * @return なし + * @details */ void euc2sjis(char *str) { @@ -252,14 +273,14 @@ void euc2sjis(char *str) } -/* - * strを環境に合った文字コードに変換し、変換前の文字コードを返す。 - * strの長さに制限はない。 - * - * 0: Unknown - * 1: ASCII (Never known to be ASCII in this function.) - * 2: EUC - * 3: SJIS +/*! + * @brief strを環境に合った文字コードに変換し、変換前の文字コードを返す。strの長さに制限はない。 + * @param str 変換する文字列のポインタ + * @return + * 0: Unknown
+ * 1: ASCII (Never known to be ASCII in this function.)
+ * 2: EUC
+ * 3: SJIS
*/ byte codeconv(char *str) { @@ -343,7 +364,12 @@ byte codeconv(char *str) return code; } -/* 文字列sのxバイト目が漢字の1バイト目かどうか判定する */ +/*! + * @brief 文字列sのxバイト目が漢字の1バイト目かどうか判定する + * @param s 判定する文字列のポインタ + * @param x 判定する位置(バイト) + * @return 漢字の1バイト目ならばTRUE + */ bool iskanji2(cptr s, int x) { int i; @@ -407,6 +433,11 @@ static const struct ms_to_jis_unicode_conv_t { {{0xef, 0xbc, 0x8d}, {0xe2, 0x88, 0x92}}, /* FULLWIDTH HYPHEN-MINUS -> MINUS SIGN */ }; +/*! + * @brief EUCがシステムコードである環境下向けにUTF-8から変換処理を行うサブルーチン + * @param str 変換する文字列のポインタ + * @return なし + */ static void ms_to_jis_unicode(char* str) { unsigned char* p; @@ -420,7 +451,6 @@ static void ms_to_jis_unicode(char* str) for (i = 0; i < sizeof(ms_to_jis_unicode_conv) / sizeof(ms_to_jis_unicode_conv[0]); ++ i) { const struct ms_to_jis_unicode_conv_t *c = &ms_to_jis_unicode_conv[i]; if (memcmp(p, c->from, 3) == 0) { - printf("hoge\n"); memcpy(p, c->to, 3); } }