unichar.h revision a0044466cc46baf25a316ea63781c60aa52b58ca
#ifndef UNICHAR_H
#define UNICHAR_H
/* Character used to replace invalid input. */
#define UNICODE_REPLACEMENT_CHAR 0xfffd
/* Characters >= base require surrogates */
#define UTF16_SURROGATE_BASE 0x10000
#define UTF16_SURROGATE_SHIFT 10
#define UTF16_SURROGATE_MASK 0x03ff
#define UTF16_SURROGATE_HIGH_FIRST 0xd800
#define UTF16_SURROGATE_HIGH_LAST 0xdbff
#define UTF16_SURROGATE_HIGH_MAX 0xdfff
#define UTF16_SURROGATE_LOW_FIRST 0xdc00
#define UTF16_SURROGATE_LOW_LAST 0xdfff
#define UTF16_SURROGATE_HIGH(chr) \
#define UTF16_SURROGATE_LOW(chr) \
extern const uint8_t *const uni_utf8_non1_bytes;
/* Returns number of characters in a NUL-terminated unicode string */
/* Translates UTF-8 input to UCS-4 output. Returns 0 if ok, -1 if input was
invalid */
/* Translates UCS-4 input to UTF-8 output. */
/* Returns 1 if *chr_r is set, 0 for incomplete trailing character,
-1 for invalid input. */
/* Returns UTF-8 string length with maximum input size. */
/* Returns the number of bytes belonging to this UTF-8 character. The given
parameter is the first byte of the UTF-8 sequence. Invalid input is
returned with length 1. */
static inline unsigned int ATTR_CONST
uni_utf8_char_bytes(char chr)
{
/* 0x00 .. 0x7f are ASCII. 0x80 .. 0xC1 are invalid. */
return 1;
}
/* Return given character in titlecase. */
/* Convert UTF-8 input to titlecase and decompose the titlecase characters to
output buffer. Returns 0 if ok, -1 if input was invalid. This generates
output that's compatible with i;unicode-casemap comparator. Invalid input
is replaced with unicode replacement character (0xfffd). */
/* If input contains only valid UTF-8 characters, return TRUE without updating
buf. If input contains invalid UTF-8 characters, replace them with unicode
replacement character (0xfffd), write the output to buf and return FALSE. */
/* Returns TRUE if string is valid UTF-8 input. */
bool uni_utf8_str_is_valid(const char *str);
#endif