Freeciv-3.3
|
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "fciconv.h"
#include "fcintl.h"
#include "log.h"
#include "mem.h"
#include "support.h"
Go to the source code of this file.
Macros | |
#define | local_encoding get_local_encoding() |
#define | data_encoding get_local_encoding() |
#define | internal_encoding get_local_encoding() |
#define | CONV_FUNC_MALLOC(src, dst) |
#define | CONV_FUNC_BUFFER(src, dst) |
#define | CONV_FUNC_STATIC(src, dst) |
Functions | |
static char * | convert_string (const char *text, const char *from, const char *to, char *buf, size_t bufsz) fc__attribute((nonnull(1 |
static char void | init_character_encodings (const char *my_internal_encoding, bool my_use_transliteration) |
const char * | get_data_encoding (void) |
const char * | get_local_encoding (void) |
const char * | get_internal_encoding (void) |
static | CONV_FUNC_STATIC (internal, local) |
size_t | get_internal_string_length (const char *text) |
void | fc_iconv_close (void) |
Variables | |
static bool | is_init = FALSE |
static char | convert_buffer [4096] |
static const char * | transliteration_string |
static char * | saved_from = nullptr |
static char * | saved_to = nullptr |
#define CONV_FUNC_BUFFER | ( | src, | |
dst | |||
) |
#define CONV_FUNC_STATIC | ( | src, | |
dst | |||
) |
#define data_encoding get_local_encoding() |
#define internal_encoding get_local_encoding() |
#define local_encoding get_local_encoding() |
|
static |
Convert the text. Both 'from' and 'to' must be 8-bit charsets. The result will be put into the buf buffer unless it is nullptr, in which case it will be allocated on demand.
Don't use this function if you can avoid it. Use one of the xxx_to_yyy_string() functions.
Definition at line 197 of file fciconv.c.
Referenced by get_internal_string_length().
Free resources allocated by the iconv system
Definition at line 418 of file fciconv.c.
Referenced by libfreeciv_free().
Return the internal encoding. This depends on the server or GUI being used.
Definition at line 182 of file fciconv.c.
Referenced by client_main(), main(), and srv_init().
Return the length, in characters, of the string. This can be used in place of strlen() in some places because it returns the number of characters not the number of bytes (with multi-byte characters in UTF-8, the two may not be the same).
Use of this function outside of GUI layout code is probably a hack. For instance the demographics code uses it, but this should instead pass the data directly to the GUI library for formatting.
Definition at line 396 of file fciconv.c.
Referenced by cmafec_get_result_descr(), dem_line_item(), helptext_extra(), insert_generated_text(), insert_veteran_help(), and report_demographics().
static char void init_character_encodings | ( | const char * | my_internal_encoding, |
bool | my_use_transliteration | ||
) |
Must be called during the initialization phase of server and client to initialize the character encodings to be used.
Pass an internal encoding of nulltpr to use the local encoding internally.
Definition at line 70 of file fciconv.c.
Referenced by client_main(), fcmp_init(), main(), and srv_init().
Definition at line 42 of file fciconv.c.
Referenced by CONV_FUNC_STATIC(), get_data_encoding(), get_internal_encoding(), get_local_encoding(), and init_character_encodings().
Definition at line 55 of file fciconv.c.
Referenced by convert_string(), and fc_iconv_close().
Definition at line 56 of file fciconv.c.
Referenced by convert_string(), and fc_iconv_close().
Definition at line 44 of file fciconv.c.
Referenced by init_character_encodings().