GFXprim
2D bitmap graphics library with emphasis on speed and correctness
|
Unicode helper macros and functions. More...
#include <stdint.h>
#include <stddef.h>
Go to the source code of this file.
Macros | |
#define | GP_UTF8_IS_ASCII(ch) (!((ch) & 0x80)) |
#define | GP_UTF8_IS_NBYTE(ch) (((ch) & 0xc0) == 0x80) |
#define | GP_UTF8_IS_2BYTE(ch) (((ch) & 0xe0) == 0xc0) |
#define | GP_UTF8_IS_3BYTE(ch) (((ch) & 0xf0) == 0xe0) |
#define | GP_UTF8_IS_4BYTE(ch) (((ch) & 0xf8) == 0xf0) |
Functions | |
static uint32_t | gp_utf8_next (const char **str) |
Parses next unicode character in UTF-8 string. | |
int8_t | gp_utf8_next_chsz (const char *str, size_t off) |
Returns number of bytes next character is occupying in an UTF-8 string. | |
int8_t | gp_utf8_prev_chsz (const char *str, size_t off) |
Returns number of bytes previous character is occupying in an UTF-8 string. | |
size_t | gp_utf8_strlen (const char *str) |
Returns a number of characters in UTF-8 string. | |
static unsigned int | gp_utf8_bytes (uint32_t unicode) |
Returns a number of bytes needed to store unicode character into UTF-8. | |
static int | gp_to_utf8 (uint32_t unicode, char *buf) |
Writes an unicode character into a UTF-8 buffer. | |
uint32_t | gp_utf_fallback (uint32_t ch) |
Attempts to strip diacritics from an unicode character. | |
Unicode helper macros and functions.
Definition in file gp_utf.h.
#define GP_UTF8_IS_2BYTE | ( | ch | ) | (((ch) & 0xe0) == 0xc0) |
#define GP_UTF8_IS_3BYTE | ( | ch | ) | (((ch) & 0xf0) == 0xe0) |
#define GP_UTF8_IS_4BYTE | ( | ch | ) | (((ch) & 0xf8) == 0xf0) |
#define GP_UTF8_IS_ASCII | ( | ch | ) | (!((ch) & 0x80)) |
#define GP_UTF8_IS_NBYTE | ( | ch | ) | (((ch) & 0xc0) == 0x80) |
|
inlinestatic |
Writes an unicode character into a UTF-8 buffer.
The buffer must be large enough!
unicode | A unicode character. |
buf | A byte buffer. |
Definition at line 141 of file gp_utf.h.
Referenced by gp_vec_ins_utf8().
|
inlinestatic |
Returns a number of bytes needed to store unicode character into UTF-8.
unicode | A unicode character. |
Definition at line 118 of file gp_utf.h.
Referenced by gp_vec_ins_utf8().
|
inlinestatic |
Parses next unicode character in UTF-8 string.
str | A pointer to the C string. |
Definition at line 35 of file gp_utf.h.
References GP_UTF8_IS_2BYTE, GP_UTF8_IS_3BYTE, GP_UTF8_IS_4BYTE, GP_UTF8_IS_ASCII, and GP_UTF8_IS_NBYTE.
Referenced by gp_utf8_pos_next(), and gp_utf8_pos_prev().
int8_t gp_utf8_next_chsz | ( | const char * | str, |
size_t | off | ||
) |
Returns number of bytes next character is occupying in an UTF-8 string.
str | A pointer to a string. |
off | An offset into the string, must point to a valid multibyte boundary. |
Referenced by gp_utf8_pos_last(), gp_utf8_pos_move(), and gp_utf8_pos_next().
int8_t gp_utf8_prev_chsz | ( | const char * | str, |
size_t | off | ||
) |
Returns number of bytes previous character is occupying in an UTF-8 string.
str | A pointer to a string. |
off | An offset into the string, must point to a valid multibyte boundary. |
Referenced by gp_utf8_pos_move(), and gp_utf8_pos_prev().
size_t gp_utf8_strlen | ( | const char * | str | ) |
Returns a number of characters in UTF-8 string.
Returns number of characters in an UTF-8 string, which may be less or equal to what strlen() reports.
str | An UTF-8 string. |
uint32_t gp_utf_fallback | ( | uint32_t | ch | ) |
Attempts to strip diacritics from an unicode character.
Attempts to strip diacritics and replace symbols with a similar meaning which produces text that can be stil readable even with ASCII only font.
ch | An UTF character. |