EasyGUI  v0.1
Platform independent GUI Library
Unicode processing

Unicode processing functions with UTF-8 character encoding. More...

Data Structures

struct  GUI_STRING_UNICODE_t
 UNICODE processing information structure. More...
 

Enumerations

enum  GUI_STRING_UNICODE_Result_t { UNICODE_OK = 0x00, UNICODE_ERROR, UNICODE_PROGRESS }
 UNICODE processing result information. More...
 

Functions

void gui_string_unicode_init (GUI_STRING_UNICODE_t *s)
 Initialize unicode processing structure. More...
 
GUI_STRING_UNICODE_Result_t gui_string_unicode_decode (GUI_STRING_UNICODE_t *s, const GUI_Char c)
 Decodes single input byte of unicode formatted text. More...
 
uint8_t gui_string_unicode_encode (const uint32_t c, GUI_Char *out)
 Encodes input character to UNICODE sequence of 1-4 bytes. More...
 

Detailed Description

Unicode processing functions with UTF-8 character encoding.

Core functions capable of encoding and decoding UTF-8 UNICODE format.

Decoding of raw unicode bytes can take up to 4 bytes in a row and stores value to 32-bit variable

UNICODE structure table
Number of bytes Bits for code point First code points Last code point Byte 1 Byte 2 Byte 3 Byte 4
1 7 U+0000 U+007F 0xxxxxxx - - -
2 11 U+0080 U+07FF 110xxxxx 10xxxxxx - -
3 16 U+0800 U+FFFF 1110xxxx 10xxxxxx 10xxxxxx -
4 21 U+10000 U+10FFFF 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx

https://en.wikipedia.org/wiki/UTF-8

Enumeration Type Documentation

UNICODE processing result information.

Enumerator
UNICODE_OK 

Indicates function successfully decode unicode sequence of 1-4 bytes

UNICODE_ERROR 

Indicates function got an error with input data from 2nd to 4th byte in UTF-8 encoding

UNICODE_PROGRESS 

Indicates function decoding is still in progress and it waits for new character

Function Documentation

GUI_STRING_UNICODE_Result_t gui_string_unicode_decode ( GUI_STRING_UNICODE_t s,
const GUI_Char  c 
)

Decodes single input byte of unicode formatted text.

Parameters
[in,out]*sPointer to working GUI_STRING_UNICODE_t structure for processing
[in]cCharacter to be used for decoding
Return values
Memberof GUI_STRING_UNICODE_Result_t indicating decoding status
See also
gui_string_unicode_init, gui_string_unicode_encode
uint8_t gui_string_unicode_encode ( const uint32_t  c,
GUI_Char out 
)

Encodes input character to UNICODE sequence of 1-4 bytes.

Parameters
[in]cCharacter to encode to UNICODE sequence
[out]*outPointer to 4-bytes long array to store UNICODE information to
Return values
Numberof bytes required for character encoding
See also
gui_string_unicode_init, gui_string_unicode_decode
void gui_string_unicode_init ( GUI_STRING_UNICODE_t s)

Initialize unicode processing structure.

Parameters
[in]*sPointer to GUI_STRING_UNICODE_t to initialize to default values
Return values
None
See also
gui_string_unicode_decode, gui_string_unicode_encode