[Freeciv-Dev] (PR#9752) 1.14 save charset in savegame
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=9752 >
This patch for 1.14 stores the charset encoding used for names in the
savegame.
This _may_ be helpful in providing compatability with the next release.
jason
Index: common/shared.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/Attic/shared.c,v
retrieving revision 1.92.2.8
diff -u -r1.92.2.8 shared.c
--- common/shared.c 6 Jan 2004 07:14:46 -0000 1.92.2.8
+++ common/shared.c 20 Aug 2004 21:29:43 -0000
@@ -1328,25 +1328,9 @@
data_encoding = "ISO-8859-1";
}
- local_encoding = getenv("FREECIV_LOCAL_ENCODING");
- if (!local_encoding) {
-#ifdef HAVE_LIBCHARSET
- local_encoding = locale_charset();
-#else
-#ifdef HAVE_LANGINFO_CODESET
- local_encoding = nl_langinfo(CODESET);
-#else
- local_encoding = "";
-#endif
-#endif
- if (strcasecmp(local_encoding, "ANSI_X3.4-1968") == 0
- || strcasecmp(local_encoding, "ASCII") == 0) {
- /* HACK: Use latin1 instead of ascii. */
- local_encoding = "ISO-8859-1";
- }
- my_snprintf(target, sizeof(target), "%s//TRANSLIT", local_encoding);
- local_encoding = target;
- }
+ local_encoding = get_local_charset();
+ my_snprintf(target, sizeof(target), "%s//TRANSLIT", local_encoding);
+ local_encoding = target;
return convert_string_malloc(text, data_encoding, local_encoding);
#else
@@ -1368,3 +1352,36 @@
return mystrdup(text);
#endif
}
+
+/***************************************************************************
+ Return the charset encoding of the local charset.
+***************************************************************************/
+char *get_local_charset(void)
+{
+#ifdef HAVE_ICONV
+ char *local_encoding;
+
+ local_encoding = getenv("FREECIV_LOCAL_ENCODING");
+ if (!local_encoding) {
+#ifdef HAVE_LIBCHARSET
+ local_encoding = locale_charset();
+#else
+#ifdef HAVE_LANGINFO_CODESET
+ local_encoding = nl_langinfo(CODESET);
+#else
+ local_encoding = "";
+#endif
+#endif
+ if (mystrcasecmp(local_encoding, "ANSI_X3.4-1968") == 0
+ || mystrcasecmp(local_encoding, "ASCII") == 0) {
+ /* HACK: Use latin1 instead of ascii. */
+ local_encoding = "ISO-8859-1";
+ }
+ }
+
+ return local_encoding;
+#else
+ /* Assume we're using latin1. */
+ return "ISO-8859-1";
+#endif
+}
Index: common/shared.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/Attic/shared.h,v
retrieving revision 1.104.2.1
diff -u -r1.104.2.1 shared.h
--- common/shared.h 4 Feb 2003 18:15:48 -0000 1.104.2.1
+++ common/shared.h 20 Aug 2004 21:29:43 -0000
@@ -179,5 +179,6 @@
const char *freeciv_motto(void);
char *convert_data_string_malloc(const char *text);
+char *get_local_charset(void);
#endif /* FC__SHARED_H */
Index: server/savegame.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v
retrieving revision 1.92.2.4
diff -u -r1.92.2.4 savegame.c
--- server/savegame.c 20 Aug 2004 19:36:08 -0000 1.92.2.4
+++ server/savegame.c 20 Aug 2004 21:29:44 -0000
@@ -2151,6 +2151,8 @@
}
secfile_insert_str(file, options, "savefile.options");
+ secfile_insert_str(file, get_local_charset(), "savefile.charset");
+
secfile_insert_int(file, game.gold, "game.gold");
secfile_insert_int(file, game.tech, "game.tech");
secfile_insert_int(file, game.skill_level, "game.skill_level");
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#9752) 1.14 save charset in savegame,
Jason Short <=
|
|