Freeciv-3.2
|
#include <stdarg.h>
#include <string.h>
#include "log.h"
#include "mem.h"
#include "support.h"
#include "fc_utf8.h"
Go to the source code of this file.
Macros | |
#define | FC_UTF8_CHAR_SIZE(utf8_char) fc_utf8_char_size[*(unsigned char *) utf8_char] |
#define | FC_UTF8_REP_CHAR "\xef\xbf\xbd" /* U+FFFD. */ |
Variables | |
const char | fc_utf8_skip [256] |
static const char | fc_utf8_char_size [256] |
Returns TRUE if the character beginning at the pointer 'utf8_char' of size 'size' is a valid UTF-8 character.
Definition at line 89 of file fc_utf8.c.
Referenced by fc_utf8_char_validate(), fc_utf8_validate(), fc_utf8_validate_len(), and fc_utf8_validate_rep_dup().
UTF-8-safe variant of fc_strlcpy() base function.
Definition at line 129 of file fc_utf8.c.
Referenced by fc_utf8_strlcat_rep(), fc_utf8_strlcpy_rep(), fc_utf8_validate_rep_dup(), and fc_utf8_validate_rep_len().
UTF-8-safe variant of fc_strlcpy() base function.
Definition at line 110 of file fc_utf8.c.
Referenced by fc_utf8_strlcat_trunc(), and fc_utf8_strlcpy_trunc().
This is a variant of cat_snprintf() to ensure the result will be a valid UTF-8 string. Unlike cat_utf8_snprintf_trunc(), it replaces the invalid characters by the replacement character, instead of truncating the string.
NB: This function doesn't perform anything on the already edited part of the string 'str', which can contain invalid UTF-8 characters.
See also cat_snprintf(), cat_utf8_snprintf_trunc().
This is a variant of cat_snprintf() to ensure the result will be a valid UTF-8 string. It truncates the string at the first UTF-8 invalid character.
NB: This function doesn't perform anything on the already edited part of the string 'str', which can contain invalid UTF-8 characters.
See also cat_snprintf(), cat_utf8_snprintf_rep().
Jump to next UTF-8 character start.
NB: This function can return a invalid UTF-8 character. Check with fc_utf8_char_validate() to ensure.
Definition at line 204 of file fc_utf8.c.
Referenced by base_fc_utf8_strlcpy_rep().
Jump to previous UTF-8 character start in the limit of the 'utf8_string' pointer. If no character is found, returns 'utf8_string'.
NB: This function can return a invalid UTF-8 character. Check with fc_utf8_char_validate() to ensure.
This is a variant of fc_snprintf() to ensure the result will be a valid UTF-8 string. Unlike fc_utf8_snprintf_trunc(), it replaces the invalid characters by the replacement character, instead of truncating the string.
See also fc_snprintf(), fc_utf8_snprintf_trunc().
This is a variant of fc_snprintf() to ensure the result will be a valid UTF-8 string. It truncates the string at the first UTF-8 invalid character.
See also fc_snprintf(), fc_utf8_snprintf_rep().
This is a variant of fc_strlcat() to ensure the result will be a valid UTF-8 string. Unlike fc_utf8_strlcat_trunc(), it replaces the invalid characters by the replacement character, instead of truncating the string.
NB: This function doesn't perform anything on the already edited part of the string 'dest', which can contain invalid UTF-8 characters.
See also fc_strlcat(), fc_utf8_strlcat_trunc().
This is a variant of fc_strlcat() to ensure the result will be a valid UTF-8 string. It truncates the string at the first UTF-8 invalid character.
NB: This function doesn't perform anything on the already edited part of the string 'dest', which can contain invalid UTF-8 characters.
See also fc_strlcat(), fc_utf8_strlcat_rep().
This is a variant of fc_strlcpy() to ensure the result will be a valid UTF-8 string. Unlike fc_utf8_strlcpy_trunc(), it replaces the invalid characters by the replacement character, instead of truncating the string.
See also fc_strlcpy(), fc_utf8_strlcpy_trunc().
This is a variant of fc_strlcpy() to ensure the result will be a valid UTF-8 string. It truncates the string at the first UTF-8 invalid character.
See also fc_strlcpy(), fc_utf8_strlcpy_rep().
Returns the number of characters in the string 'utf8_string'. To know the number of used bytes, used strlen() instead.
NB: 'utf8_string' must be UTF-8 valid (see fc_utf8_validate()), or the behaviour of this function will be unknown.
Returns TRUE if the string 'utf8_string' contains only valid UTF-8 characters. If 'end' is not NULL, the end of the valid string will be stored there, even if it returns TRUE.
See also fc_utf8_validate_len().
Definition at line 239 of file fc_utf8.c.
Referenced by fc_utf8_validate_trunc(), fc_utf8_validate_trunc_dup(), fc_utf8_vsnprintf_rep(), and fc_utf8_vsnprintf_trunc().
Returns TRUE if the string 'utf8_string' contains only valid UTF-8 characters in the limit of the length (in bytes) 'byte_len'. If 'end' is not NULL, the end of the valid string will be stored there, even if it returns TRUE.
See also fc_utf8_validate().
Definition at line 268 of file fc_utf8.c.
Referenced by base_fc_utf8_strlcpy_rep(), base_fc_utf8_strlcpy_trunc(), and fc_utf8_validate_trunc_len().
Duplicate 'utf8_string' and replace all invalid characters with the replacement character.
See also fc_utf8_validate_rep_len(), and fc_utf8_validate_trunc_dup().
Transform 'utf8_string' with replacing all invalid characters with the replacement character in the limit of 'byte_len', truncate the last character. Returns 'utf8_string'.
See also fc_utf8_validate_len(), fc_utf8_validate_trunc(), and fc_utf8_validate_rep_dup().
Definition at line 368 of file fc_utf8.c.
Referenced by fc_utf8_vsnprintf_rep().
Truncate the string 'utf8_string' at the first invalid UTF-8 character. Returns 'utf8_string'.
See also fc_utf8_validate(), fc_utf8_validate_trunc_len(), and fc_utf8_validate_trunc_dup().
Duplicate the truncation of the string 'utf8_string' at the first invalid UTF-8 character.
See also fc_utf8_validate_trunc(), fc_utf8_validate_trunc_len(), and fc_utf8_validate_rep_dup().
Truncate the string 'utf8_string' at the first invalid UTF-8 character in the limit (in bytes) of 'byte_len'. Returns 'utf8_string'.
See also fc_utf8_validate_trunc(), fc_utf8_validate_trunc_dup(), and fc_utf8_validate_rep_len().
This is a variant of fc_vsnprintf() to ensure the result will be a valid UTF-8 string. Unlike fc_utf8_vsnprintf_trunc(), it replaces the invalid characters by the replacement character, instead of truncating the string.
See also fc_vsnprintf(), fc_utf8_vsnprintf_trunc().
Definition at line 578 of file fc_utf8.c.
Referenced by cat_utf8_snprintf_rep(), and fc_utf8_snprintf_rep().
This is a variant of fc_vsnprintf() to ensure the result will be a valid UTF-8 string. It truncates the string at the first UTF-8 invalid character.
See also fc_vsnprintf(), fc_utf8_vsnprintf_rep().
Definition at line 552 of file fc_utf8.c.
Referenced by cat_utf8_snprintf_trunc(), fc_utf8_snprintf_trunc(), and send_chat_printf().