18
18
#include "shared.h"
23
- There are three encodings used by freeciv: the data encoding, the
24
internal encoding, and the local encoding. Each is a character set
25
(like utf-8 or latin1). Each string in the code must be in one of these
26
three encodings; to cut down on bugs always document whenever you have
27
a string in anything other than the internal encoding and never make
28
global variables hold anything other than the internal encoding; the
29
local and data encodings should only be used locally within the code
30
and always documented as such.
32
- The data_encoding is used in all data files and network transactions.
35
- The internal_encoding is used internally within freeciv. This is always
36
UTF-8 at the server, but can be configured by the GUI client. The GTK2
37
client uses UTF-8 here but other clients will use whatever their GUI
38
library or platform requires. By using the GUI encoding internally at
39
the client it allows us to pass any strings directly to the GUI without
40
needing to convert them. The drawback is that we have to convert them
41
into the data encoding before sending them over the network (a likely
42
source of bugs). Also, gettext is set up to always return strings in
43
the internal encoding.
45
- The local_encoding is the one supported on the command line, which is
46
generally the value listed in the $LANG environment variable. This is
47
not under freeciv control; all output to the command line must be
48
converted or it will not display correctly.
52
- Translation files are not controlled by freeciv iconv. The .po files
53
can be in any character set, as set at the top of the file.
55
- All translatable texts should be American English ASCII. In the past,
56
gettext documentation has always said to stick to ASCII for the gettext
57
input (pre-translated texts) and rely on translations to supply the
58
needed non-ASCII characters.
60
- All other texts, including rulesets, nations, and code files must be in
61
UTF-8 (ASCII is a subset of UTF-8, and is fine for use here).
63
- The server uses UTF-8 for everything; UTF-8 is the server's "internal
66
- Everything sent over the network is always in UTF-8.
68
- Everything in the client is converted into the client's "internal
69
encoding" when it is received from the server. Depending on which
70
GUI is used, this may be just about any character set. Conversely when
71
sending strings from the client to the server they need to be converted
72
into the data encoding. This should be done internally within the
75
- Everything printed to the command line must be converted into the
76
"local encoding" which may be anything as defined by the system. Using
77
fc_fprintf is generally the easiest way to print to the command line
78
in which case all strings passed to it should be in the internal
81
See PR#40028 in the old RT for additional explanation.
20
84
#define FC_DEFAULT_DATA_ENCODING "UTF-8"
22
86
void init_character_encodings(const char *internal_encoding,