EasyGUI  Version v1.0
String functions

String functions with UNICODE support. More...

Modules

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

Data Structures

struct  gui_string_t
 String structure for parsing characters. More...
 

Functions

size_t gui_string_length (const gui_char *const src)
 Return length of string. More...
 
size_t gui_string_lengthtotal (const gui_char *const src)
 Return total number of bytes required for string. More...
 
gui_chargui_string_copy (gui_char *const dst, const gui_char *const src)
 Copy string from source to destination no matter of GUI_CFG_USE_UNICODE selection. More...
 
gui_chargui_string_copyn (gui_char *const dst, const gui_char *const src, size_t len)
 Copy string from source to destination with selectable number of bytes. More...
 
int gui_string_compare (const gui_char *const s1, const gui_char *const s2)
 Compare 2 strings. More...
 
uint8_t gui_string_isprintable (uint32_t ch)
 Check if character is printable. More...
 
uint8_t gui_string_prepare (gui_string_t *const s, const gui_char *const str)
 Prepare string before it can be used with gui_string_getch or gui_string_getchreverse functions. More...
 
uint8_t gui_string_getch (gui_string_t *const str, uint32_t *const out, uint8_t *const len)
 Get next decoded character from source string. More...
 
uint8_t gui_string_getchreverse (gui_string_t *const str, uint32_t *const out, uint8_t *const len)
 Get character by character from end of string up. More...
 
uint8_t gui_string_gotoend (gui_string_t *const str)
 Set character pointer to the last character in sequence. More...
 

Detailed Description

String functions with UNICODE support.

Function Documentation

◆ gui_string_compare()

int gui_string_compare ( const gui_char *const  s1,
const gui_char *const  s2 
)

Compare 2 strings.

Parameters
[in]s1First string address
[in]s2Second string address
Returns
0 if equal, non-zero otherwise

◆ gui_string_copy()

gui_char* gui_string_copy ( gui_char *const  dst,
const gui_char *const  src 
)

Copy string from source to destination no matter of GUI_CFG_USE_UNICODE selection.

Parameters
[out]dstDestination memory address
[in]srcSource memory address
Returns
Pointer to destination memory

◆ gui_string_copyn()

gui_char* gui_string_copyn ( gui_char *const  dst,
const gui_char *const  src,
size_t  len 
)

Copy string from source to destination with selectable number of bytes.

Parameters
[out]dstDestination memory address
[in]srcSource memory address
[in]lenNumber of bytes to copy
Returns
Pointer to destination memory

◆ gui_string_getch()

uint8_t gui_string_getch ( gui_string_t *const  s,
uint32_t *const  out,
uint8_t *const  len 
)

Get next decoded character from source string.

Note
When GUI_CFG_USE_UNICODE is set to 1, multiple bytes may be used for single character
Parameters
[in,out]sPointer to gui_string_t structure with input string. Function will internally change pointer of actual string where it points to to next character
[out]outPointer to output memory where output character will be saved
[out]lenPointer to output memory where number of bytes for string will be saved
Returns
1 on success, 0 otherwis
See also
gui_string_getchreverse

◆ gui_string_getchreverse()

uint8_t gui_string_getchreverse ( gui_string_t *const  str,
uint32_t *const  out,
uint8_t *const  len 
)

Get character by character from end of string up.

Note
Functionality is the same as gui_string_getch except order is swapped
String must be at the last character before function is first time called
Note
When GUI_CFG_USE_UNICODE is set to 1, multiple bytes may be used for single character
Parameters
[in,out]*strPointer to gui_string_t structure with input string. Function will internally change pointer of actual string where it points to to next character
[out]outPointer to output memory where output character will be saved
[out]lenPointer to output memory where number of bytes for string will be saved
Returns
1 on success, 0 otherwise

◆ gui_string_gotoend()

uint8_t gui_string_gotoend ( gui_string_t *const  str)

Set character pointer to the last character in sequence.

Parameters
[in,out]strPointer to gui_string_t structure with string informations
Returns
1 on success, 0 otherwise

◆ gui_string_isprintable()

uint8_t gui_string_isprintable ( uint32_t  ch)

Check if character is printable.

Parameters
[in]chFirst memory address
Returns
1 on success, 0 otherwise

◆ gui_string_length()

size_t gui_string_length ( const gui_char *const  src)

Return length of string.

Example input string: EasyGUI\xDF\x8F

  1. When GUI_CFG_USE_UNICODE is set to 1, function will try to parse unicode characters and will return 8 on top input string
  2. When GUI_CFG_USE_UNICODE is set to 0, function will count all the bytes until string termination is reached and will return 9 on top input string
Parameters
[in]srcPointer to source string to get length
Returns
Number of visible characters in string

◆ gui_string_lengthtotal()

size_t gui_string_lengthtotal ( const gui_char *const  src)

Return total number of bytes required for string.

Note
When GUI_CFG_USE_UNICODE is set to 0, this function returns the same as gui_string_length
Parameters
[in]srcPointer to source string to get length
Returns
Number of visible characters in string

◆ gui_string_prepare()

uint8_t gui_string_prepare ( gui_string_t *const  s,
const gui_char *const  str 
)

Prepare string before it can be used with gui_string_getch or gui_string_getchreverse functions.

Parameters
[in,out]sPointer to gui_string_t as base string object
[in]strPointer to gui_char with string used for manipulation
Returns
1 on success, 0 otherwise