|
SWILIB API (NSG)
|
Function for working with UTF-16 pascal-style strings.
Usage: #include <swilib.h> or #include <swilib/wstring.h>
Data Structures | |
| struct | WSBODY |
| Wide-string body. More... | |
| struct | WSHDR |
| Wide-string header. More... | |
Macros | |
| #define | wsbody(ws) ((WSBODY *) ((ws)->wsbody)) |
Typedefs | |
| typedef struct WSBODY | WSBODY |
| typedef struct WSHDR | WSHDR |
Functions | |
| WSHDR * | AllocWS (int size) |
| Create new empty WSHDR. | |
| WSHDR * | CreateWS (malloc_func_t malloc_func, mfree_func_t mfree_func, int size) |
| Create new empty WSHDR with custom allocator. | |
| WSHDR * | CreateLocalWS (WSHDR *header, uint16_t *body, int size) |
| Initialize new empty WSHDR with static allocation. | |
| void | FreeWS (WSHDR *str) |
| Free WSHDR. | |
| void | CutWSTR (WSHDR *str, int length) |
| Truncate string. | |
| void | wsAppendChar (WSHDR *destination, int character) |
| Append a character to the end of WSHDR. | |
| uint16_t | wsCharAt (const WSHDR *str, short pos) |
| Get charater at the given position (safe). | |
| int | GetUnicodeSymbolByDynIcon (int dyn_icon) |
| Get character by dynamic icon id. | |
| int | wsInsertChar (WSHDR *destination, int character, int position) |
| Insert a character at the given position of the WSHDR. | |
| void | wsRemoveChars (WSHDR *destination, int position, int length) |
| Remove characters from the WSHDR. | |
| WSHDR * | wstrcpy (WSHDR *destination, WSHDR *source) |
| Copy WSHDR. | |
| uint16_t * | wstrcopy (uint16_t *destination, const uint16_t *source) |
| Copy WSHDR body. | |
| WSHDR * | wstrncpy (WSHDR *destination, WSHDR *source, int num) |
| Copy characters from WSHDR. | |
| void | wstrcpybypos (WSHDR *destination, WSHDR *source, int from, int num) |
| Copy characters from WSHDR. | |
| WSHDR * | wstrcat (WSHDR *destination, WSHDR *source) |
| Concatenate two WSHDR. | |
| WSHDR * | wstrncat (WSHDR *destination, WSHDR *source, int num) |
| Concatenate two WSHDR. | |
| short | wstrchr (WSHDR *str, uint32_t start, uint32_t character) |
| Locate first occurrence of character in WSHDR. | |
| short | wstrrchr (WSHDR *str, uint32_t rstart, uint32_t character) |
| Locate last occurrence of character in WSHDR. | |
| int | wstrcmp (const WSHDR *str1, const WSHDR *str2) |
| Compare two WSHDR strings. | |
| int | wstrncmp (const WSHDR *ws1, const WSHDR *ws2, size_t n) |
| Compare two WSHDR strings, up to a specific length. | |
| int | wstricmp (const WSHDR *ws1, const WSHDR *ws2) |
| Compare two WSHDR strings without case sensitivity. | |
| int | wstrnicmp (const WSHDR *ws1, const WSHDR *ws2, size_t n) |
| Compare two WSHDR strings without case sensitivity, up to a specific length. | |
| uint16_t | wstrlen (const WSHDR *str) |
| Get WSHDR length. | |
| uint16_t | wstriwstr (const WSHDR *ws, const WSHDR *search, uint32_t start_pos) |
| Find the first occurrence of a substring in a WSHDR string, ignoring case, starting from given position. | |
| void | wstrreplace (WSHDR *dest, const WSHDR *src, uint32_t pos) |
| Replace substring in dest with src starting from position pos. | |
Formatting | |
| int | wsprintf (WSHDR *s, const char *format,...) |
| Write formatted output to WSHDR. | |
| void | wstrcatprintf (WSHDR *s, const char *format,...) |
| Append formatted output to the end of WSHDR. | |
Encoding converting | |
| int | ws_2utf8 (const WSHDR *source, char *destination, int *new_length, uint32_t size) |
| Convert WSHDR to the UTF-8 C-string. | |
| int | utf8_2ws (WSHDR *destination, const char *source, uint32_t size) |
| Convert UTF-8 C-string to WSHDR. | |
| int | str_2ws (WSHDR *destination, const char *source, uint32_t size) |
| Convert CP1252 (Latin) C-string to WSHDR. | |
| void | ws_2str (const WSHDR *source, char *destination, uint32_t size) |
| Convert WSHDR to the UTF-8 C-string with special mark. | |
| void | wstrtoupper (WSHDR *ws) |
| Convert WSHDR string to uppercase in-place. | |
| void | wstrtolower (WSHDR *ws) |
| Convert WSHDR string to lowercase in-place. | |
| void | wstrcapitalize (WSHDR *ws) |
| Convert WSHDR string to capitalized form in-place (first character uppercase, rest lowercase) | |
| struct WSBODY |
| struct WSHDR |
| WSHDR * AllocWS | ( | int | size | ) |
| WSHDR * CreateWS | ( | malloc_func_t | malloc_func, |
| mfree_func_t | mfree_func, | ||
| int | size ) |
| void CutWSTR | ( | WSHDR * | str, |
| int | length ) |
Truncate string.
| str | pointer to the destination WSHDR |
| length | length to which the string should be reduced |
| void wsAppendChar | ( | WSHDR * | destination, |
| int | character ) |
Get charater at the given position (safe).
| str | pointer to the WSHDR |
| pos | position |
| int GetUnicodeSymbolByDynIcon | ( | int | dyn_icon | ) |
Get character by dynamic icon id.
| dyn_icon | dynamic icon id, more than 2000 |
| int wsInsertChar | ( | WSHDR * | destination, |
| int | character, | ||
| int | position ) |
| void wsRemoveChars | ( | WSHDR * | destination, |
| int | position, | ||
| int | length ) |
| uint16_t * wstrcopy | ( | uint16_t * | destination, |
| const uint16_t * | source ) |
| short wstrchr | ( | WSHDR * | str, |
| uint32_t | start, | ||
| uint32_t | character ) |
| short wstrrchr | ( | WSHDR * | str, |
| uint32_t | rstart, | ||
| uint32_t | character ) |
Compare two WSHDR strings.
Compare two WSHDR strings, up to a specific length.
Compare two WSHDR strings without case sensitivity, up to a specific length.
Find the first occurrence of a substring in a WSHDR string, ignoring case, starting from given position.
| ws | WSHDR string to search in |
| search | WSHDR substring to search for (case-insensitive) |
| start_pos | starting position in ws |
Write formatted output to WSHDR.
Additional placeholders:
%t - CP1251 string (cyrillic)%s - CP1252 string (latin)%w - UTF-16 string (WSHDR)| [out] | s | pointer to a WSHDR where the resulting string is stored, the buffer should be large enough to contain the resulting string |
| format | C-string that contains a format string that follows the same specifications as standart format in any sprintf/printf (CP1252, latin) |
Append formatted output to the end of WSHDR.
Additional placeholders:
%t - CP1251 string (cyrillic)%s - CP1252 string (latin)%w - UTF-16 string (WSHDR)| [out] | s | pointer to a WSHDR where the resulting string is stored, the buffer should be large enough to contain the resulting string |
| format | C-string that contains a format string that follows the same specifications as standart format in any sprintf/printf (CP1252, latin) |
Convert WSHDR to the UTF-8 C-string.
| source | input WSHDR to be converted to C-string |
| destination | pointer to the destination C-string, which should be large enough to contain the source WSHDR |
| new_length | pointer to which to write the length of the destination string |
| size | size of the destination buffer, including space for the terminating null |
Convert UTF-8 C-string to WSHDR.
| destination | pointer to the destination WSHDR, which should be large enough to contain the source string |
| source | input C-string to be converted to WSHDR |
| size | maximum number of source bytes to read |
Convert WSHDR to the UTF-8 C-string with special mark.
| source | input WSHDR to be converted to C-string |
| destination | pointer to the destination C-string, which should be large enough to contain the source WSHDR |
| size | maximum number of characters to be converted (+1) |
Also, 0x1F (mark of UTF-8 string) will be added at the beginning of the string. This is useful for filesystem functions.
| void wstrtoupper | ( | WSHDR * | ws | ) |
| void wstrtolower | ( | WSHDR * | ws | ) |