Freeciv-3.1: /fast/freeciv/nightly/S3_1/utility/fc_utf8.h File Reference

Freeciv-3.1

Loading...
Searching...
No Matches
Macros | Functions | Variables
fc_utf8.h File Reference

Go to the source code of this file.

## Macros

#define | fc_ut8_next_char(utf8_char) (utf8_char + fc_utf8_skip[*(unsigned char *) utf8_char])

## Functions

bool | fc_utf8_char_validate (const char *utf8_char) fc__attribute((nonnull(1)))
const char * | fc_utf8_find_next_char (const char *utf8_char) fc__attribute((nonnull(1)))
const char * | fc_utf8_find_prev_char (const char *utf8_char, const char *utf8_string) fc__attribute((nonnull(1
bool | fc_utf8_validate (const char *utf8_string, const char **end) fc__attribute((nonnull(1)))
bool | fc_utf8_validate_len (const char *utf8_string, size_t byte_len, const char **end) fc__attribute((nonnull(1)))
char * | fc_utf8_validate_trunc (char *utf8_string) fc__attribute((nonnull(1)))
char * | fc_utf8_validate_trunc_len (char *utf8_string, size_t byte_len) fc__attribute((nonnull(1)))
char * | fc_utf8_validate_trunc_dup (const char *utf8_string) fc__attribute((nonnull(1))) fc__attribute((warn_unused_result))
char * | fc_utf8_validate_rep_len (char *utf8_string, size_t byte_len) fc__attribute((nonnull(1)))
char * | fc_utf8_validate_rep_dup (const char *utf8_string) fc__attribute((nonnull(1))) fc__attribute((warn_unused_result))
size_t | fc_utf8_strlen (const char *utf8_string) fc__attribute((nonnull(1)))
size_t | fc_utf8_strlcpy_trunc (char *dest, const char *src, size_t n) fc__attribute((nonnull(1
size_t size_t | fc_utf8_strlcpy_rep (char *dest, const char *src, size_t n) fc__attribute((nonnull(1
size_t size_t size_t | fc_utf8_strlcat_trunc (char *dest, const char *src, size_t n) fc__attribute((nonnull(1
size_t size_t size_t size_t | fc_utf8_strlcat_rep (char *dest, const char *src, size_t n) fc__attribute((nonnull(1
size_t size_t size_t size_t int | fc_utf8_snprintf_trunc (char *str, size_t n, const char *format,...) fc__attribute((__format__(__printf__
size_t size_t size_t size_t int | fc__attribute ((nonnull(1, 3)))
int | fc_utf8_snprintf_rep (char *str, size_t n, const char *format,...) fc__attribute((__format__(__printf__
int | fc_utf8_vsnprintf_trunc (char *str, size_t n, const char *format, va_list args) fc__attribute((nonnull(1
int int | fc_utf8_vsnprintf_rep (char *str, size_t n, const char *format, va_list args) fc__attribute((nonnull(1
int int int | cat_utf8_snprintf_trunc (char *str, size_t n, const char *format,...) fc__attribute((__format__(__printf__
int | cat_utf8_snprintf_rep (char *str, size_t n, const char *format,...) fc__attribute((__format__(__printf__

## Variables

const char | fc_utf8_skip [256]

## Macro Definition Documentation

## ◆ fc_ut8_next_char

#define fc_ut8_next_char | ( |  | utf8_char | ) | (utf8_char + fc_utf8_skip[*(unsigned char *) utf8_char])

Definition at line 42 of file fc_utf8.h.

## Function Documentation

## ◆ cat_utf8_snprintf_rep()

int cat_utf8_snprintf_rep | ( | char * | str,
|  | size_t | n,
|  | const char * | format,
|  |  | ...
| ) |  |

## ◆ cat_utf8_snprintf_trunc()

int int int cat_utf8_snprintf_trunc | ( | char * | str,
|  | size_t | n,
|  | const char * | format,
|  |  | ...
| ) |  |

## ◆ fc__attribute()

int int fc__attribute | ( | (nonnull(1, 3)) |  | ) |

## ◆ fc_utf8_char_validate()

bool fc_utf8_char_validate | ( | const char * | utf8_char | ) |

Returns TRUE if the character beginning at the pointer 'utf8_char' is a valid UTF-8 character.

Definition at line 193 of file fc_utf8.c.

## ◆ fc_utf8_find_next_char()

const char * fc_utf8_find_next_char | ( | const char * | utf8_char | ) |

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().

## ◆ fc_utf8_find_prev_char()

const char * fc_utf8_find_prev_char | ( | const char * | utf8_char,
|  | const char * | utf8_string
| ) |  |

## ◆ fc_utf8_snprintf_rep()

int fc_utf8_snprintf_rep | ( | char * | str,
|  | size_t | n,
|  | const char * | format,
|  |  | ...
| ) |  |

## ◆ fc_utf8_snprintf_trunc()

size_t size_t size_t size_t int fc_utf8_snprintf_trunc | ( | char * | str,
|  | size_t | n,
|  | const char * | format,
|  |  | ...
| ) |  |

## ◆ fc_utf8_strlcat_rep()

size_t size_t size_t size_t fc_utf8_strlcat_rep | ( | char * | dest,
|  | const char * | src,
|  | size_t | n
| ) |  |

## ◆ fc_utf8_strlcat_trunc()

size_t size_t size_t fc_utf8_strlcat_trunc | ( | char * | dest,
|  | const char * | src,
|  | size_t | n
| ) |  |

## ◆ fc_utf8_strlcpy_rep()

size_t size_t fc_utf8_strlcpy_rep | ( | char * | dest,
|  | const char * | src,
|  | size_t | n
| ) |  |

## ◆ fc_utf8_strlcpy_trunc()

size_t fc_utf8_strlcpy_trunc | ( | char * | dest,
|  | const char * | src,
|  | size_t | n
| ) |  |

## ◆ fc_utf8_strlen()

size_t fc_utf8_strlen | ( | const char * | utf8_string | ) |

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.

Definition at line 425 of file fc_utf8.c.

## ◆ fc_utf8_validate()

bool fc_utf8_validate | ( | const char * | utf8_string,
|  | const char ** | end
| ) |  |

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().

## ◆ fc_utf8_validate_len()

bool fc_utf8_validate_len | ( | const char * | utf8_string,
|  | size_t | byte_len,
|  | const char ** | end
| ) |  |

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().

## ◆ fc_utf8_validate_rep_dup()

char * fc_utf8_validate_rep_dup | ( | const char * | utf8_string | ) |

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().

Definition at line 386 of file fc_utf8.c.

## ◆ fc_utf8_validate_rep_len()

char * fc_utf8_validate_rep_len | ( | char * | utf8_string,
|  | size_t | byte_len
| ) |  |

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().

## ◆ fc_utf8_validate_trunc()

char * fc_utf8_validate_trunc | ( | char * | utf8_string | ) |

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().

Definition at line 309 of file fc_utf8.c.

## ◆ fc_utf8_validate_trunc_dup()

char * fc_utf8_validate_trunc_dup | ( | const char * | utf8_string | ) |

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().

Definition at line 345 of file fc_utf8.c.

## ◆ fc_utf8_validate_trunc_len()

char * fc_utf8_validate_trunc_len | ( | char * | utf8_string,
|  | size_t | byte_len
| ) |  |

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().

Definition at line 327 of file fc_utf8.c.

## ◆ fc_utf8_vsnprintf_rep()

int int fc_utf8_vsnprintf_rep | ( | char * | str,
|  | size_t | n,
|  | const char * | format,
|  | va_list | args
| ) |  |

## ◆ fc_utf8_vsnprintf_trunc()

int fc_utf8_vsnprintf_trunc | ( | char * | str,
|  | size_t | n,
|  | const char * | format,
|  | va_list | args
| ) |  |

## Variable Documentation

## ◆ fc_utf8_skip

const char fc_utf8_skip[256]

extern

Definition at line 31 of file fc_utf8.c.