27#ifdef HAVE_LANGINFO_CODESET
32#include <libcharset.h>
50# define local_encoding get_local_encoding()
51# define data_encoding get_local_encoding()
52# define internal_encoding get_local_encoding()
93#ifdef HAVE_LANGINFO_CODESET
127#ifdef FREECIV_ENABLE_NLS
132 fprintf(
stderr,
"Encodings: Data=%s, Local=%s, Internal=%s\n",
139 _(
"You are running Freeciv without using iconv. Unless\n"
140 "you are using the UTF-8 character set, some characters\n"
141 "may not be displayed properly. You can download iconv\n"
142 "at https://gnu.org/.\n"));
166# ifdef HAVE_LIBCHARSET
169# ifdef HAVE_LANGINFO_CODESET
249 const char *
mytext = text;
260 iconv(
cd,
nullptr,
nullptr,
nullptr,
nullptr);
263 if (
res == (
size_t) (-1)) {
267 fprintf(
stderr,
"Invalid string conversion from %s to %s: %s.\n",
308#define CONV_FUNC_MALLOC(src, dst) \
309char *src ## _to_ ## dst ## _string_malloc(const char *text) \
311 const char *encoding1 = (dst ## _encoding); \
312 char encoding[strlen(encoding1) + strlen(transliteration_string) + 1]; \
314 fc_snprintf(encoding, sizeof(encoding), \
315 "%s%s", encoding1, transliteration_string); \
316 return convert_string(text, (src ## _encoding), \
317 (encoding), nullptr, 0); \
320#define CONV_FUNC_BUFFER(src, dst) \
321char *src ## _to_ ## dst ## _string_buffer(const char *text, \
322 char *buf, size_t bufsz) \
324 const char *encoding1 = (dst ## _encoding); \
325 char encoding[strlen(encoding1) + strlen(transliteration_string) + 1]; \
327 fc_snprintf(encoding, sizeof(encoding), \
328 "%s%s", encoding1, transliteration_string); \
329 return convert_string(text, (src ## _encoding), \
330 encoding, buf, bufsz); \
333#define CONV_FUNC_STATIC(src, dst) \
334char *src ## _to_ ## dst ## _string_static(const char *text) \
336 (src ## _to_ ## dst ## _string_buffer)(text, \
338 sizeof(convert_buffer)); \
339 return convert_buffer; \
size_t get_internal_string_length(const char *text)
#define CONV_FUNC_BUFFER(src, dst)
static char convert_buffer[4096]
static const char * transliteration_string
void fc_iconv_close(void)
#define CONV_FUNC_MALLOC(src, dst)
const char * get_data_encoding(void)
#define internal_encoding
static char * convert_string(const char *text, const char *from, const char *to, char *buf, size_t bufsz) fc__attribute((nonnull(1
const char * get_internal_encoding(void)
#define CONV_FUNC_STATIC(src, dst)
static char void init_character_encodings(const char *my_internal_encoding, bool my_use_transliteration)
const char * get_local_encoding(void)
#define FC_DEFAULT_DATA_ENCODING
void fc_fprintf(FILE *stream, const char *format,...) fc__attribute((__format__(__printf__
#define fc_assert_ret_val(condition, val)
static int recursion[AIT_LAST]
int fc_snprintf(char *str, size_t n, const char *format,...)
int fc_strcasecmp(const char *str0, const char *str1)
int fc_vsnprintf(char *str, size_t n, const char *format, va_list ap)