![]() |
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) |
| #define | GP_UTF8_IS_NBYTE(ch) |
| #define | GP_UTF8_IS_2BYTE(ch) |
| #define | GP_UTF8_IS_3BYTE(ch) |
| #define | GP_UTF8_IS_4BYTE(ch) |
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. | |
| static size_t | gp_utf16_to_utf8_size (uint16_t *chars, size_t chars_len) |
| Calculates a size for an utf8 string to hold utf16 characters. | |
| static void | gp_utf16_to_utf8 (uint16_t *chars, size_t chars_len, char *dest) |
| Convers utf16 characters into an utf8 string. | |
| static size_t | gp_utf32_to_utf8_size (uint32_t *chars, size_t chars_len) |
| Calculates a size for an utf8 string to hold utf32 characters. | |
| static void | gp_utf32_to_utf8 (uint32_t *chars, size_t chars_len, char *dest) |
| Convers utf32 characters into an utf8 string. | |
| 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 | ) |
Returns true if we have first unicode byte of two byte sequence
Definition at line 22 of file gp_utf.h.
Referenced by gp_utf8_next().
| #define GP_UTF8_IS_3BYTE | ( | ch | ) |
Returns true if we have first unicode byte of three byte sequence
Definition at line 24 of file gp_utf.h.
Referenced by gp_utf8_next().
| #define GP_UTF8_IS_4BYTE | ( | ch | ) |
Returns true if we have first unicode byte of four byte sequence
Definition at line 26 of file gp_utf.h.
Referenced by gp_utf8_next().
| #define GP_UTF8_IS_ASCII | ( | ch | ) |
Returns true if unicode byte is ASCII
Definition at line 18 of file gp_utf.h.
Referenced by gp_utf8_next().
| #define GP_UTF8_IS_NBYTE | ( | ch | ) |
Returns true if we have first unicode byte of single byte sequence
Definition at line 20 of file gp_utf.h.
Referenced by gp_utf8_next().
|
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_utf16_to_utf8(), gp_utf32_to_utf8(), and gp_vec_ins_utf8().
|
inlinestatic |
Convers utf16 characters into an utf8 string.
| chars | An array of utf16 characters. |
| chars_len | The lenth of the utf16 array. |
| dest | A buffer large enough to store the utf16 characters and terminating null character. This can be calculated by gp_utf16_to_utf8_size(). |
Definition at line 204 of file gp_utf.h.
References gp_to_utf8().
|
inlinestatic |
Calculates a size for an utf8 string to hold utf16 characters.
| chars | An array of utf16 characters. |
| chars_len | The lenth of the utf16 array. |
Definition at line 177 of file gp_utf.h.
References gp_utf8_bytes().
|
inlinestatic |
Convers utf32 characters into an utf8 string.
| chars | An array of utf32 characters. |
| chars_len | The lenth of the utf16 array. |
| dest | A buffer large enough to store the utf32 characters and terminating null character. This can be calculated by gp_utf32_to_utf8_size(). |
Definition at line 251 of file gp_utf.h.
References gp_to_utf8().
|
inlinestatic |
Calculates a size for an utf8 string to hold utf32 characters.
| chars | An array of utf32 characters. |
| chars_len | The lenth of the utf32 array. |
Definition at line 224 of file gp_utf.h.
References gp_utf8_bytes().
|
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_utf16_to_utf8_size(), gp_utf32_to_utf8_size(), and 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. |