mirror of
https://git.zap.org.au/git/trader.git
synced 2024-12-04 14:46:45 -05:00
Try loading UTF-8 strings with transliteration, if at all possible
Also fix a bug in save_game(): the iconv_open() parameters were the wrong way around!
This commit is contained in:
parent
cf944c58f6
commit
150bcf10c2
14
src/fileio.c
14
src/fileio.c
@ -258,9 +258,17 @@ bool load_game (int num)
|
|||||||
}
|
}
|
||||||
need_icd = (strcmp(codeset, GAME_FILE_CHARSET) != 0);
|
need_icd = (strcmp(codeset, GAME_FILE_CHARSET) != 0);
|
||||||
if (need_icd) {
|
if (need_icd) {
|
||||||
icd = iconv_open(codeset, GAME_FILE_CHARSET);
|
// Try using the GNU libiconv "//TRANSLIT" option
|
||||||
|
strcpy(buf, codeset);
|
||||||
|
strcat(buf, GAME_FILE_TRANSLIT);
|
||||||
|
|
||||||
|
icd = iconv_open(buf, GAME_FILE_CHARSET);
|
||||||
if (icd == (iconv_t) -1) {
|
if (icd == (iconv_t) -1) {
|
||||||
errno_exit("iconv_open");
|
// Try iconv_open() without "//TRANSLIT"
|
||||||
|
icd = iconv_open(codeset, GAME_FILE_CHARSET);
|
||||||
|
if (icd == (iconv_t) -1) {
|
||||||
|
errno_exit("iconv_open");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
icd = (iconv_t) -1;
|
icd = (iconv_t) -1;
|
||||||
@ -469,7 +477,7 @@ bool save_game (int num)
|
|||||||
}
|
}
|
||||||
need_icd = (strcmp(codeset, GAME_FILE_CHARSET) != 0);
|
need_icd = (strcmp(codeset, GAME_FILE_CHARSET) != 0);
|
||||||
if (need_icd) {
|
if (need_icd) {
|
||||||
icd = iconv_open(codeset, GAME_FILE_CHARSET);
|
icd = iconv_open(GAME_FILE_CHARSET, codeset);
|
||||||
if (icd == (iconv_t) -1) {
|
if (icd == (iconv_t) -1) {
|
||||||
errno_exit("iconv_open");
|
errno_exit("iconv_open");
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,7 @@
|
|||||||
|
|
||||||
#ifdef USE_UTF8_GAME_FILE
|
#ifdef USE_UTF8_GAME_FILE
|
||||||
# define GAME_FILE_CHARSET "UTF-8" // For strings in game file
|
# define GAME_FILE_CHARSET "UTF-8" // For strings in game file
|
||||||
|
# define GAME_FILE_TRANSLIT "//TRANSLIT" // Transliterate (GNU libiconv)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define BUFSIZE 1024 // For various string buffers
|
#define BUFSIZE 1024 // For various string buffers
|
||||||
|
Loading…
Reference in New Issue
Block a user