-/*
-**
-** $Id: jlib.c,v 1.14 2008-05-03 15:40:59 argrath Exp $
-**
-*/
-
-/* Copyright (c) Issei Numata 1994-2000 */
+/* JNetHack Copyright */
+/* (c) Issei Numata 1994-2000 */
+/* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2018 */
/* JNetHack may be freely redistributed. See license for details. */
#include <stdio.h>
/* default input kcode */
#ifndef INPUT_KCODE
-# ifdef MSDOS
+# if defined(MSDOS) || defined(WIN32)
# define INPUT_KCODE SJIS
# else
-# define INPUT_KCODE EUC
+# define INPUT_KCODE UTF8
# endif
#endif
/* default output kcode */
#ifndef OUTPUT_KCODE
-# ifdef MSDOS
+# if defined(MSDOS) || defined(WIN32)
# define OUTPUT_KCODE SJIS
# else
-# define OUTPUT_KCODE EUC
+# define OUTPUT_KCODE UTF8
# endif
#endif
#ifdef POSIX_ICONV
if (input_dsc) {
size_t src_len, dst_len;
- up = s;
+ up = (unsigned char *)s;
src_len = strlen(s);
dst_len = sizeof(buf);
if (iconv(input_dsc, (char**)&up, &src_len,
#else
if( IC==EUC && input_kcode == SJIS ){
while(*s){
- up = s;
+ up = (unsigned char *)s;
if(is_kanji(*up)){
pp = sj2e((unsigned char *)s);
*(p++) = pp[0];
#ifdef POSIX_ICONV
if(output_dsc){
size_t src_len, dst_len;
- up = s;
+ up = (unsigned char *)s;
src_len = strlen(s);
dst_len = sizeof(buf);
if(iconv(output_dsc, (char**)&up, &src_len,
#else
if( IC==EUC && output_kcode == SJIS ){
while(*s){
- up = s;
+ up = (unsigned char *)s;
if( *up & 0x80 ){
pp = e2sj((unsigned char *)s);
*(p++) = pp[0];
return c;
}
} else {
- return is_kanji2(s, pos);
+ return is_kanji2((char *)s, pos);
}
}
unsigned char cc[3];
if(IC==SJIS)
- memcpy(cc, (char *)sj2e(c), 2);
+ memcpy(cc, (char *)sj2e((unsigned char *)c), 2);
else
memcpy(cc, c, 2);
if(!is_kanji1(engr, nxt)) return 0;
j = kanji2index(engr[nxt], engr[nxt + 1]);
- if (j >= 0x0000 && j <= 0x02B1) p = &ro0[j << 2];
- else if (j >= 0x0582 && j <= 0x1116) p = &ro1[(j - 0x0582) << 2];
- else if (j >= 0x1142 && j <= 0x1E7F) p = &ro2[(j - 0x1142) << 2];
- else p = "\81H";
+ if (j >= 0x0000 && j <= 0x02B1)
+ p = (unsigned char *)&ro0[j << 2];
+ else if (j >= 0x0582 && j <= 0x1116)
+ p = (unsigned char *)&ro1[(j - 0x0582) << 2];
+ else if (j >= 0x1142 && j <= 0x1E7F)
+ p = (unsigned char *)&ro2[(j - 0x1142) << 2];
+ else p = (unsigned char *)"\81H";
if (p[2] != ' ' || p[3] != ' ') p += select_rnd * 2;
engr[nxt] = *p++;