sombok  2.4.0
Functions
utf8

Handle UTF-8 sequence. More...

Functions

unistr_tsombok_decode_utf8 (unistr_t *unistr, size_t maxchars, const char *utf8, size_t utf8len, int check)
 
char * sombok_encode_utf8 (char *utf8, size_t *utf8lenp, size_t maxbytes, unistr_t *unistr)
 

Detailed Description

Handle UTF-8 sequence.

Note
This module was introduced by release 2.1.0.

Function Documentation

◆ sombok_decode_utf8()

unistr_t* sombok_decode_utf8 ( unistr_t unistr,
size_t  maxchars,
const char *  utf8,
size_t  utf8len,
int  check 
)

Decode UTF-8 string to Unicode string

Parameters
[out]unistrUnicode string, must not be NULL.
[in]maxcharsmaximum number of characters to be decoded. 0 means infinite
[in]utf8source UTF-8 string
[in]utf8lenlength of string
[in]check0: no check; 1: check malformed sequence; 2: check surrogate too; 3: check codes beyond Unicode too
Returns
Unicode string. If unistr->str was NULL or maxchars was 0 (infinite), required buffer will be (re-)allocated. If error occurred, NULL is returned and errno is set.
Note
unistr->str must not point to static memory.

◆ sombok_encode_utf8()

char* sombok_encode_utf8 ( char *  utf8,
size_t *  utf8lenp,
size_t  maxbytes,
unistr_t unistr 
)

Encode Unicode string to UTF-8 string

Parameters
[out]utf8string buffer, may be NULL.
[out]utf8lenppointer to length of buffer, may be NULL.
[in]maxbytesmaximum number of bytes to be encoded. 0 means infinite
[in]unistrsource Unicode string, must not be NULL.
Returns
string buffer. If utf8 was NULL or maxbytes was 0 (infinite), required buffer will be (re-)allocated. If error occurred, NULL is returned and errno is set.
Note
utf8 must not point to static memory.