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
10
src/fileio.c
10
src/fileio.c
@ -258,10 +258,18 @@ bool load_game (int num)
|
||||
}
|
||||
need_icd = (strcmp(codeset, GAME_FILE_CHARSET) != 0);
|
||||
if (need_icd) {
|
||||
// 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) {
|
||||
// Try iconv_open() without "//TRANSLIT"
|
||||
icd = iconv_open(codeset, GAME_FILE_CHARSET);
|
||||
if (icd == (iconv_t) -1) {
|
||||
errno_exit("iconv_open");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
icd = (iconv_t) -1;
|
||||
}
|
||||
@ -469,7 +477,7 @@ bool save_game (int num)
|
||||
}
|
||||
need_icd = (strcmp(codeset, GAME_FILE_CHARSET) != 0);
|
||||
if (need_icd) {
|
||||
icd = iconv_open(codeset, GAME_FILE_CHARSET);
|
||||
icd = iconv_open(GAME_FILE_CHARSET, codeset);
|
||||
if (icd == (iconv_t) -1) {
|
||||
errno_exit("iconv_open");
|
||||
}
|
||||
|
@ -58,6 +58,7 @@
|
||||
|
||||
#ifdef USE_UTF8_GAME_FILE
|
||||
# define GAME_FILE_CHARSET "UTF-8" // For strings in game file
|
||||
# define GAME_FILE_TRANSLIT "//TRANSLIT" // Transliterate (GNU libiconv)
|
||||
#endif
|
||||
|
||||
#define BUFSIZE 1024 // For various string buffers
|
||||
|
Loading…
Reference in New Issue
Block a user