Site Logo

maxdz Software GmbH

en | de
Home

Team

Products

mdz_ui

mdz_xml

mdz_string

mdz_vector

mdzWebSiteGenerator

mdzTennisTracker

Shop

Legals

Contacts

mdz_string Overview and Reference

mdz_string - very lightweight and versatile C library for handling single-byte (ASCII/ANSI) strings and Unicode strings. Source code of library is highly-portable, conforms to ANSI C 89/90 Standard. Builds for Win32/Win64, Linux, FreeBSD, Android, macOS are available.

Summary: Basically, conversion of Unicode strings between ANSI, UTF8, UTF16-LE, UTF16-BE, UTF32-LE and UTF32-BE formats are possible. This all with ANSI C89/90 conforming code, without any further dependencies!

mdz_string Advantages

1. High portability: the whole code conforms to ANSI C 89/90 Standard. Multithreading/asynchronous part is POSIX compatible (under UNIX/Linux).

2. Little dependencies: basically, mdz_string functions are only dependent on standard C-library memory-management/access functions. Multithreading part is dependent on POSIX pthreads API (under UNIX/Linux) and old process control/synchronization API (from Windows 2000). It means you can use library in your code without any further dependencies except standard platform libraries/APIs.

3. Fast: Our single-byte (ASCII/ANSI) strings are very fast, concerning operations like searching, insertion, deletion, etc. especially for very large (like hundreds of megabytes or gigabytes) strings.

4. Flexibilty: nearly all functions our single-byte (ASCII/ANSI) strings, contain not only "left position" but also "right position" parameters to limit processed area from right. Also library contains more string functions than according STL, boost or glib analogs have.

5. Extended error-checking: all functions preserve internal error-code pointing the problem. It is possible to use strict error-checking (when all preserved error-codes should be MDZ_ERROR_NONE) or "relaxed"-checking - when only returned mdz_false will indicate error.

6. Extended control: strings do only explicit operations. It means for example, when "insert" function is called - it will return error if there is not enough capacity in string. No implicit reservations will be made.

7. Attached usage: strings should not necessarily use dynamically-allocated memory - which may be not available on your embedded system (or if malloc()/free() are forbidden to use in you safety-critical software). Just attach string/data to your statically-allocated memory and use all string functionality.

8. Cache-friendly: it is possible to keep controlling and data parts together in memory using "embedded part".

9. Unicode support: UTF-8, UTF-16, UTF-32 are supported.

10. wchar_t support: also wchar_t strings are supported, with 2 and 4 bytes-large wchar_t characters.

11. Endianness-aware strings: wchar, utf16 and utf32 strings are endiannes-aware thus may be used to produce and manipulate strings with pre-defined endianness even if endianness of host differs.

12. Unicode "surrogate-pairs" awareness: 2-byte Unicode strings correctly process/distinguish "surrogate-pairs" as 1 Unicode symbol.

13. Asynchronous execution: almost all functions of single-byte (ASCII/ANSI) strings and insert functions of Unicode strings can be executed asynchronously.

Please refer to mdz_string Wiki for API details.


mdz_string API Reference

mdz_ansi Reference
mdz_wchar Reference
mdz_utf8 Reference
mdz_utf16 Reference
mdz_utf32 Reference

Asynchronous execution

Many functions of mdz_string accept parameters for asynchronous execution.
The only relevant parameter is:

- struct mdz_asyncData* pAsyncData - pointer to shared async data for asynchronous call, or NULL if call should be synchronous

Fields of struct mdz_asyncData* are following:

TypeParameterDescription
void* m_pStringPointer to string instance
mdz_bool m_bFinishedmdz_true if the call is completely finished. Otherwise mdz_false (if interrupted/cancelled)
size_t m_nResultResult of call. Invalid if call is not completely finished (m_bFinished is mdz_false)
void* m_pDataAdditional data returned by call (if any). Invalid if call is not completely finished (m_bFinished is mdz_false)
mdz_bool m_bCancelShould be set by client in mdz_true during call execution, to cancel the call. Otherwise mdz_false
pthread_t / HANDLE m_hThreadHandle to thread on which the call is executed. May be used by client for wait operations


mdz_string API Reference is generated using mdzApiRefGenerator.

mdz_string General Information and Functions

mdz_string initialization functions.

mdz_string_init

Initializes mdz_string library. This function should be called before any other function of the library.

mdz_bool mdz_string_init(const uint32_t* pFirstNameHash, const uint32_t* pLastNameHash, const uint32_t* pEmailHash, const uint32_t* pLicenseHash);

ParameterDescription
pFirstNameHashuser first name hash code
pLastNameHashuser last name hash code
pEmailHashuser e-mail hash code
pLicenseHashlicense hash code

ReturnDescription
mdz_trueif the initialization has succeed, otherwise false

mdz_string Reference

mdz_string_init_attached

Initializes mdz_string library. This function should be caled before any other function of the library.
Memory for license data starts at position pStart. Size of internal initialization structure is returned in pSize.

mdz_bool mdz_string_init_attached(const uint32_t* pFirstNameHash, const uint32_t* pLastNameHash, const uint32_t* pEmailHash, const uint32_t* pLicenseHash, const char* pStart, size_t nAreaSize, size_t* pOutSize);

ParameterDescription
pFirstNameHashuser first name hash code
pLastNameHashuser last name hash code
pEmailHashuser e-mail hash code
pLicenseHashlicense hash code
pStartmemory start position of license data
nAreaSizesize of available memory from pStart in bytes. Should be large enough for license data (> 500 bytes)
pOutSizeactual size of placed license data in bytes

ReturnDescription
mdz_trueif the initialization has succeed, otherwise false

mdz_string Reference

mdz_string_uninit

Un-initializes mdz_string library and frees corresponding memory allocations.

void mdz_string_uninit(void);

mdz_string Reference


mdz_ansi API Reference is generated using mdzApiRefGenerator.

mdz_ansi General Information and Functions

mdz_ansi is dynamically-sized contiguous single-byte string, containing ASCII (0..127) and "ANSI" (128 - 255) characters.

Capacity - how many bytes of memory is reserved.
Size - how many characters are actually residing in a string, excluding terminating 0.

"reserve" functions allocate/reallocate memory dynamically using malloc()/realloc().
"attach" functionality allows attaching contiguous block of memory to string, for using string functions on it.

Init and destroy functions:

mdz_ansi_create
mdz_ansi_create_attached
mdz_ansi_destroy
mdz_ansi_clear
mdz_ansi_attachData

Reserve capacity functions:

mdz_ansi_reserve
mdz_ansi_reserveAndInit_async
mdz_ansi_capacity
mdz_ansi_size
mdz_ansi_offsetFromStart
mdz_ansi_isAttachedData
mdz_ansi_embedSize

Insert/remove functions:

mdz_ansi_insert_async
mdz_ansi_append_async
mdz_ansi_removeFrom_async
mdz_ansi_remove_async
mdz_ansi_trimLeft_async
mdz_ansi_trimRight_async
mdz_ansi_trim_async

Find functions:

mdz_ansi_findSingle_async
mdz_ansi_find_async
mdz_ansi_firstOf_async
mdz_ansi_firstNotOf_async
mdz_ansi_rfindSingle_async
mdz_ansi_rfind_async
mdz_ansi_lastOf_async
mdz_ansi_lastNotOf_async

Miscellaneous functions:

mdz_ansi_compare_async
mdz_ansi_replace_async
mdz_ansi_count_async
mdz_ansi_copySubAnsi_async
mdz_ansi_copySubAnsiFrom_async


mdz_ansi_create

Create empty string with Capacity and Size 0.

struct mdz_Ansi* mdz_ansi_create(size_t nEmbedSize);

ParameterDescription
nEmbedSizesize of "embedded part" of string. There is no "embedded part" if 0

ReturnDescription
NULLif library is not initialized with mdz_string_init() call
NULLif memory allocation failed
Resultpointer to string for use in other mdz_ansi functions

mdz_ansi Reference

mdz_ansi_create_attached

Create empty string with Capacity and Size 0. Memory for mdz_Ansi structure starts at position pStart. Size of internal ansi structure (it is usually bigger than mdz_Ansi) is returned in pSize.

struct mdz_Ansi* mdz_ansi_create_attached(const void* pStart, size_t nAreaSizeBytes, size_t* pOutSize);

ParameterDescription
pStartmemory start position of mdz_Ansi structure
nAreaSizeBytessize of available memory from pStart in bytes. Should be large enough for internal Ansi structure
pOutSizereturned actual size of placed internal ansi structure in bytes, may be NULL if not needed

ReturnDescription
NULLif library is not initialized with mdz_string_init() call
NULLif pStart == NULL or pSize == NULL
NULLif size in nSize is smaller than size of internal ansi structure
Resultpointer to string for use in other mdz_Ansi functions. Normally it equals to pStart

mdz_ansi Reference

mdz_ansi_destroy

Destroy string including underlying data.
If string is attached using mdz_ansi_createAttached(), string controlling data will not be destroyed.
If string data is attached using mdz_ansi_attachData(), m_pData will not be destroyed.

void mdz_ansi_destroy(const struct mdz_Ansi* psAnsi);

ParameterDescription
psAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()

mdz_ansi Reference

mdz_ansi_clear

Clear m_pData of string with setting Size in 0.

void mdz_ansi_clear(struct mdz_Ansi* psAnsi);

ParameterDescription
psAnsipointer to string returned by mdz_ansi_create()

mdz_ansi Reference

mdz_ansi_attachData

Attach pre-allocated data to string, assigning pcData to m_pData. If attached, m_pData will not be destroyed in mdz_ansi_destroy()

mdz_bool mdz_ansi_attachData(struct mdz_Ansi* psAnsi, const char* pData, size_t nOffsetFromStart, size_t nCapacity, enum mdz_attach_type enAttachType);

ParameterDescription
psAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
pDatapointer to pre-allocated data to attach
nOffsetFromStartposition in pre-allocated data to attach from. Can be > 0
nCapacityfull capacity of pre-allocated data in items
enAttachTypetype of attachment. 0 is expected at position pData[nOffsetFromStart] if MDZ_ATTACH_ZEROSIZE. 0 is expected at position pData[nCapacity - 1] if MDZ_ATTACH_SIZE_TERMINATOR

ReturnDescription
mdz_falseif psAnsi == NULL
mdz_falseif pData == NULL (MDZ_ERROR_DATA), or nOffsetFromStart >= nCapacity (MDZ_ERROR_OFFSET)
mdz_falseif enAttachType is MDZ_ATTACH_ZEROSIZE or MDZ_ATTACH_SIZE_TERMINATOR but 0 is not found at expected position (MDZ_ERROR_ATTACH_TERMINATOR)
mdz_trueoperation succeeded

mdz_ansi Reference

mdz_ansi_reserve

Reserve nNewCapacity items for string. String Size does not change. Reservation is not made if m_pData is attached using mdz_ansi_attachData()

mdz_bool mdz_ansi_reserve(struct mdz_Ansi* psAnsi, size_t nNewCapacity);

ParameterDescription
psAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nNewCapacitynew capacity in items to reserve

ReturnDescription
mdz_falseif psAnsi == NULL
mdz_falseif memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif nNewCapacity > Capacity and m_pData is attached using mdz_ansi_attachData() (MDZ_ERROR_ATTACHED)
mdz_trueif nNewCapacity <= Capacity (MDZ_ERROR_CAPACITY)
mdz_true reservation succeeded

mdz_ansi Reference

mdz_ansi_reserveAndInit_async

Reserve nNewCapacity items for string and initializes all items in cItem. May be called only on empty string (with Size == 0). After call, string Size equals to Capacity-1.
Reservation is not made if m_pData is attached using mdz_ansi_attachData() and nNewCapacity > Capacity

mdz_bool mdz_ansi_reserveAndInit_async(struct mdz_Ansi* psAnsi, size_t nNewCapacity, char cItem, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_reserveAndInit(psAnsi, nNewCapacity, cItem);

ParameterDescription
psAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nNewCapacitycapacity to reserve in items
cItemitem for string initialization
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif psAnsi == NULL
mdz_falseif memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif Size > 0 (MDZ_ERROR_NONEMPTY)
mdz_falseif nNewCapacity > Capacity and m_pData is attached using mdz_ansi_attachData() (MDZ_ERROR_ATTACHED)
mdz_trueif nNewCapacity <= Capacity (MDZ_ERROR_CAPACITY), initialization succeeded
mdz_truereservation and initialization succeeded

mdz_ansi Reference

mdz_ansi_capacity

Return string Capacity in items.

size_t mdz_ansi_capacity(const struct mdz_Ansi* psAnsi);

ParameterDescription
psAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()

ReturnDescription
SIZE_MAXif psAnsi == NULL
Capacityotherwise

mdz_ansi Reference

mdz_ansi_size

Return string Size in items.

size_t mdz_ansi_size(const struct mdz_Ansi* psAnsi);

ParameterDescription
psAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()

ReturnDescription
SIZE_MAXif psAnsi == NULL
Sizeotherwise

mdz_ansi Reference

mdz_ansi_offsetFromStart

Return string OffsetFromStart in items.

size_t mdz_ansi_offsetFromStart(const struct mdz_Ansi* psAnsi);

ParameterDescription
psAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()

ReturnDescription
SIZE_MAXif psAnsi == NULL
OffsetFromStartotherwise

mdz_ansi Reference

mdz_ansi_isAttachedData

Return if string data is attached.

mdz_bool mdz_ansi_isAttachedData(const struct mdz_Ansi* psAnsi);

ParameterDescription
psAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()

ReturnDescription
mdz_falseif psAnsi == NULL
mdz_falseif string data is not attached
mdz_trueif string data is attached

mdz_ansi Reference

mdz_ansi_embedSize

Return string "embedded part" Size in items.

size_t mdz_ansi_embedSize(const struct mdz_Ansi* psAnsi);

ParameterDescription
psAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()

ReturnDescription
SIZE_MAXif psAnsi == NULL
Result"embedded part" Size otherwise

mdz_ansi Reference

mdz_ansi_insert_async

Insert nCount items in string. String m_pData and pItems cannot overlap, if reservation is allowed. Size grows on nCount.

mdz_bool mdz_ansi_insert_async(struct mdz_Ansi* psAnsi, size_t nLeftPos, const char* pcItems, size_t nCount, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_insert(psAnsi, nLeftPos, pcItems, nCount, bReserve);

ParameterDescription
psAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based position to insert. If nLeftPos == Size or SIZE_MAX, items are appended. nLeftPos > Size is not allowed
pcItemsitems to insert
nCountnumber of items to insert or 0 if pcItems until 0-terminator should be used
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif psAnsi == NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_ansi_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_trueif pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 and pcItems[0] == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Size (MDZ_ERROR_BIGLEFT), or nCount is too big (MDZ_ERROR_BIGCOUNT). No insertion is made
mdz_trueinsertion succeeded

mdz_ansi Reference

mdz_ansi_append_async

Append nCount items in string. String m_pData and pItems cannot overlap, if reservation is allowed. Size grows on nCount.

mdz_bool mdz_ansi_append_async(struct mdz_Ansi* psAnsi, const char* pcItems, size_t nCount, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_append(psAnsi, pcItems, nCount, bReserve);

ParameterDescription
psAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
pcItemsitems to insert
nCountnumber of items to insert or 0 if pcItems until 0-terminator should be used
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif psAnsi == NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_ansi_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_trueif pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 and pcItems[0] == 0 (MDZ_ERROR_ZEROCOUNT), or nCount is too big (MDZ_ERROR_BIGCOUNT). No insertion is made
mdz_trueinsertion succeeded

mdz_ansi Reference

mdz_ansi_findSingle_async

Find first occurrence of cItem in string. Returns 0-based position of match (if found), or string Size if not found, or SIZE_MAX if error.

size_t mdz_ansi_findSingle_async(const struct mdz_Ansi* psAnsi, size_t nLeftPos, size_t nRightPos, char cItem, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_findSingle(psAnsi, nLeftPos, nRightPos, cItem);

ParameterDescription
psAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based start position to search from left. Use 0 to search from the beginning of string
nRightPos0-based end position to search up to. Use Size-1 or SIZE_MAX to search till the end of string
cItemcharacter to find
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
SIZE_MAXif psAnsi == NULL
Sizeif nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT). No search is made
Sizeif item(s) not found
Result0-based position of first match

mdz_ansi Reference

mdz_ansi_find_async

Find first occurrence of pcItems in string. Returns 0-based position of match (if found), or string Size if not found, or SIZE_MAX if error.

size_t mdz_ansi_find_async(const struct mdz_Ansi* psAnsi, size_t nLeftPos, size_t nRightPos, const char* pcItems, size_t nCount, enum mdz_find_method enFindMethod, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_find(psAnsi, nLeftPos, nRightPos, pcItems, nCount, enFindMethod);

ParameterDescription
psAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based start position to search from left. Use 0 to search from the beginning of string
nRightPos0-based end position to search up to. Use Size-1 or SIZE_MAX to search till the end of string
pcItemspointer to items to find
nCountnumber of items to find or 0 if pcItems until 0-terminator should be used
enFindMethodfind method to use. See details in mdz_find_method description
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
SIZE_MAXif psAnsi == NULL
Sizeif pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 and pcItems[0] == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT), or nCount is too big (MDZ_ERROR_BIGCOUNT), or invalid enFindMethod (MDZ_ERROR_FINDMETHOD). No search is made
Sizeif item(s) not found
Result0-based position of first match

mdz_ansi Reference

mdz_ansi_firstOf_async

Find first occurrence of any item of pcItems in string. Returns 0-based position of match (if found), or string Size if not found, or SIZE_MAX if error.

size_t mdz_ansi_firstOf_async(const struct mdz_Ansi* psAnsi, size_t nLeftPos, size_t nRightPos, const char* pcItems, size_t nCount, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_firstOf(psAnsi, nLeftPos, nRightPos, pcItems, nCount);

ParameterDescription
psAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based start position to search from left. Use 0 to search from the beginning of string
nRightPos0-based end position to search up to. Use Size-1 or SIZE_MAX to search till the end of string
pcItemspointer to items to find
nCountnumber of items to find or 0 if pcItems until 0-terminator should be used
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
SIZE_MAXif psAnsi == NULL
Sizeif pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 and pcItems[0] == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT). No search is made
Sizeif item(s) not found
Result0-based position of first match

mdz_ansi Reference

mdz_ansi_firstNotOf_async

Find first non-occurrence of any item of pcItems in string. Returns 0-based position of match (if found), or string Size if not found, or SIZE_MAX if error.

size_t mdz_ansi_firstNotOf_async(const struct mdz_Ansi* psAnsi, size_t nLeftPos, size_t nRightPos, const char* pcItems, size_t nCount, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_firstNotOf(psAnsi, nLeftPos, nRightPos, pcItems, nCount);

ParameterDescription
psAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based start position to search from left. Use 0 to search from the beginning of string
nRightPos0-based end position to search up to. Use Size-1 or SIZE_MAX to serch till the end of string
pcItemspointer to items to find
nCountnumber of items to find or 0 if pcItems until 0-terminator should be used
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
SIZE_MAXif psAnsi == NULL
Sizeif pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 and pcItems[0] == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT). No search is made
Sizeif non-occurence is not found
Result0-based position of first match

mdz_ansi Reference

mdz_ansi_rfindSingle_async

Find last occurrence of cItem in string. Returns 0-based position of match (if found), or string Size if not found, or SIZE_MAX if error.

size_t mdz_ansi_rfindSingle_async(const struct mdz_Ansi* psAnsi, size_t nLeftPos, size_t nRightPos, char cItem, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_rfindSingle(psAnsi, nLeftPos, nRightPos, cItem);

ParameterDescription
psAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based end position to find up to. Use 0 to search till the beginning of string
nRightPos0-based start position to find from right. Use Size-1 or SIZE_MAX to serch from the end of string
cItemcharacter to find
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
SIZE_MAXif psAnsi == NULL
Sizeif nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT). No search is made
Sizeif item(s) not found
Result0-based position of first match

mdz_ansi Reference

mdz_ansi_rfind_async

Find last occurrence of pcItems in string. Returns 0-based position of match (if found), or string Size if not found, or SIZE_MAX if error.

size_t mdz_ansi_rfind_async(const struct mdz_Ansi* psAnsi, size_t nLeftPos, size_t nRightPos, const char* pcItems, size_t nCount, enum mdz_find_method enFindMethod, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_rfind(psAnsi, nLeftPos, nRightPos, pcItems, nCount, enFindMethod);

ParameterDescription
psAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based end position to find up to. Use 0 to search till the beginning of string
nRightPos0-based start position to find from right. Use Size-1 or SIZE_MAX to serch from the end of string
pcItemspointer to items to find
nCountnumber of items to find or 0 if pcItems until 0-terminator should be used
enFindMethodfind method to use. See details in mdz_find_method description
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
SIZE_MAXif psAnsi == NULL
Sizeif pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 and pcItems[0] == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT), or nCount is too big (MDZ_ERROR_BIGCOUNT), or invalid enFindMethod (MDZ_ERROR_FINDMETHOD). No search is made
Sizeif item(s) not found
Result0-based position of first match

mdz_ansi Reference

mdz_ansi_lastOf_async

Find last occurrence of any item of pcItems in string. Returns 0-based position of match (if found), or string Size if not found, or SIZE_MAX if error.

size_t mdz_ansi_lastOf_async(const struct mdz_Ansi* psAnsi, size_t nLeftPos, size_t nRightPos, const char* pcItems, size_t nCount, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_lastOf(psAnsi, nLeftPos, nRightPos, pcItems, nCount);

ParameterDescription
psAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based end position to search up to. Use 0 to search till the beginning of string
nRightPos0-based start position to search from right. Use Size-1 or SIZE_MAX to serch from the end of string
pcItemspointer to items to find
nCountnumber of items to find or 0 if pcItems until 0-terminator should be used
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
SIZE_MAXif psAnsi == NULL
Sizeif pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 and pcItems[0] == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT). No search is made
Sizeif item(s) not found
Result0-based position of first match

mdz_ansi Reference

mdz_ansi_lastNotOf_async

Find last non-occurrence of any item of pcItems in string. Returns 0-based position of match (if found), or string Size if not found, or SIZE_MAX if error.

size_t mdz_ansi_lastNotOf_async(const struct mdz_Ansi* psAnsi, size_t nLeftPos, size_t nRightPos, const char* pcItems, size_t nCount, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_lastNotOf(psAnsi, nLeftPos, nRightPos, pcItems, nCount);

ParameterDescription
psAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based end position to search up to. Use 0 to search till the beginning of string
nRightPos0-based start position to search from right. Use Size-1 or SIZE_MAX to serch from the end of string
pcItemspointer to items to find
nCountnumber of items to find or 0 if pcItems until 0-terminator should be used
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
SIZE_MAXif psAnsi == NULL
Sizeif pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 and pcItems[0] == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT). No search is made
Sizeif non-occurence is not found
Result0-based position of first match

mdz_ansi Reference

mdz_ansi_removeFrom_async

Remove nCount item(s) starting from 0-based nLeftPos position. After the operation, Capacity doesn't change, Size decreases on nCount.

mdz_bool mdz_ansi_removeFrom_async(struct mdz_Ansi* psAnsi, size_t nLeftPos, size_t nCount, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_removeFrom(psAnsi, nLeftPos, nCount);

ParameterDescription
psAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based start position to remove item(s) from. Use 0 to remove from the beginning of string
nCountnumber of item(s) to remove or 0 if pcItems until 0-terminator should be used
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif psAnsi == NULL
mdz_trueif nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nCount is too big (MDZ_ERROR_BIGCOUNT), or nLeftPos + nCount > Size (MDZ_ERROR_BIGLEFT). No removes are made
mdz_trueoperation succeeded

mdz_ansi Reference

mdz_ansi_remove_async

Remove all ocurrences of nCount item(s) matching to pcItems, residing between nLeftPos and nRightPos. After remove(s) Capacity doesn't change, Size decreases on nCount of removed items.

mdz_bool mdz_ansi_remove_async(struct mdz_Ansi* psAnsi, size_t nLeftPos, size_t nRightPos, const char* pcItems, size_t nCount, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_remove(psAnsi, nLeftPos, nRightPos, pcItems, nCount);

ParameterDescription
psAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based start position to remove item(s) from. Use 0 to search from the beginning of string
nRightPos0-based end position to remove item(s) up to. Use Size-1 or SIZE_MAX to serch till the end of string
pcItemspointer to items to remove
nCountnumber of item(s) to remove or 0 if pcItems until 0-terminator should be used
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif psAnsi == NULL
mdz_trueif pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 and pcItems[0] == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT), or nCount is too big (MDZ_ERROR_BIGCOUNT). No removes are made
mdz_trueoperation succeeded

mdz_ansi Reference

mdz_ansi_trimLeft_async

Remove items which are contained in pcItems from left, until first non-contained in pcItems item is reached.

mdz_bool mdz_ansi_trimLeft_async(struct mdz_Ansi* psAnsi, size_t nLeftPos, size_t nRightPos, const char* pcItems, size_t nCount, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_trimLeft(psAnsi, nLeftPos, nRightPos, pcItems, nCount);

ParameterDescription
psAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based start position to trim item(s) from left. Use 0 to trim from the beginning of string
nRightPos0-based end position to trim item(s) up to. Use Size-1 or SIZE_MAX to trim till the end of string
pcItemspointer to items to remove
nCountnumber of items to remove or 0 if pcItems until 0-terminator should be used
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif psAnsi == NULL
mdz_trueif string is empty (MDZ_ERROR_EMPTY), or pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT). No trims are made
mdz_trueoperation succeeded

mdz_ansi Reference

mdz_ansi_trimRight_async

Remove items which are contained in pcItems from right, until first non-contained in pcItems item is reached.

mdz_bool mdz_ansi_trimRight_async(struct mdz_Ansi* psAnsi, size_t nLeftPos, size_t nRightPos, const char* pcItems, size_t nCount, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_trimRight(psAnsi, nLeftPos, nRightPos, pcItems, nCount);

ParameterDescription
psAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based end position to trim item(s) up to. Use 0 to trim till the beginning of string
nRightPos0-based start position to trim item(s) from right. Use Size-1 or SIZE_MAX to trim from the end of string
pcItemspointer to items to remove
nCountnumber of items to remove or 0 if pcItems until 0-terminator should be used
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif psAnsi == NULL
mdz_trueif string is empty (MDZ_ERROR_EMPTY), or pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 and pcItems[0] == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT). No removes are made
mdz_trueoperation succeeded

mdz_ansi Reference

mdz_ansi_trim_async

Remove items which are contained in pcItems from left and from right, until first non-contained in pcItems item is reached.

mdz_bool mdz_ansi_trim_async(struct mdz_Ansi* psAnsi, size_t nLeftPos, size_t nRightPos, const char* pcItems, size_t nCount, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_trim(psAnsi, nLeftPos, nRightPos, pcItems, nCount);

ParameterDescription
psAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based start position to trim item(s) from left. Use 0 to trim from the beginning of string
nRightPos0-based start position to trim item(s) from right. Use Size-1 or SIZE_MAX to trim from the end of string
pcItemspointer to items to remove
nCountnumber of items to remove or 0 if pcItems until 0-terminator should be used
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif psAnsi == NULL
mdz_trueif string is empty (MDZ_ERROR_EMPTY), or pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 and pcItems[0] == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT). No removes are made
mdz_trueoperation succeeded, otherwise mdz_false

mdz_ansi Reference

mdz_ansi_compare_async

Compare content of string with pcItems.

enum mdz_compare_result mdz_ansi_compare_async(const struct mdz_Ansi* psAnsi, size_t nLeftPos, const char* pcItems, size_t nCount, mdz_bool bPartialCompare, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_compare(psAnsi, nLeftPos, pcItems, nCount, bPartialCompare);

ParameterDescription
psAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based start position to compare from. Use 0 to compare from the beginning of string
pcItemspointer to items to compare
nCountnumber of items to compare or 0 if pcItems until 0-terminator should be used
bPartialCompareif mdz_true compare only nCount items, otherwise compare full strings
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
MDZ_COMPARE_ERRORif psAnsi == NULL
MDZ_COMPARE_NONEQUALif pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 and pcItems[0] == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos >= Size (MDZ_ERROR_BIGLEFT), or nCount is too big (MDZ_ERROR_BIGCOUNT). No comparison is made
MDZ_COMPARE_EQUAL or MDZ_COMPARE_NONEQUALResult of comparison

mdz_ansi Reference

mdz_ansi_replace_async

Replace every occurence of pcItemsBefore with pcItemsAfter. There should be enough Capacity for replacing data.

mdz_bool mdz_ansi_replace_async(struct mdz_Ansi* psAnsi, size_t nLeftPos, size_t nRightPos, const char* pcItemsBefore, size_t nCountBefore, const char* pcItemsAfter, size_t nCountAfter, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_replace(psAnsi, nLeftPos, nRightPos, pcItemsBefore, nCountBefore, pcItemsAfter, nCountAfter, bReserve);

ParameterDescription
psAnsipointer to astring returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based start position to search for replace from. Use 0 to search from the beginning of string
nRightPos0-based end position to search for replace up to. Use Size-1 or SIZE_MAX to seach till the end of string
pcItemsBeforepointer to items to replace
nCountBeforenumber of items to replace or 0 if pcItems until 0-terminator should be used
pcItemsAfterpointer to items to replace with
nCountAfternumber of items to replace with or 0 if pcItems until 0-terminator should be used
bReserveif mdz_true reserve capacity when there is not enough space for replacement, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif psAnsi == NULL
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_ansi_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_trueif pcItemsBefore == NULL (MDZ_ERROR_ITEMS), or nCountBefore == 0 and pcItemsBefore[0] == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT), or nCountBefore is too big (MDZ_ERROR_BIGCOUNT). No replacements are made
mdz_trueoperation succeeded

mdz_ansi Reference

mdz_ansi_count_async

Counts number of pcItems substring occurences in string.

size_t mdz_ansi_count_async(const struct mdz_Ansi* psAnsi, size_t nLeftPos, size_t nRightPos, const char* pcItems, size_t nCount, enum mdz_find_method enFindMethod, mdz_bool bAllowOverlapped, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_count(psAnsi, nLeftPos, nRightPos, pcItems, nCount, enFindMethod, bAllowOverlapped);

ParameterDescription
psAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based start position to count from. Use 0 to count from the beginning of string
nRightPos0-based end position to count up to. Use Size-1 or SIZE_MAX to count till the end of string
pcItemsitems/substring to count
nCountSize of substring to count or 0 if pcItems until 0-terminator should be used
enFindMethodfind method to use. See details in mdz_find_method description
bAllowOverlappedmdz_true if overlapped substrings should be counted, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
SIZE_MAXif psAnsi == NULL
0if pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 and pcItems[0] == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT), or nCount is too big (MDZ_ERROR_BIGCOUNT), or invalid enFindMethod (MDZ_ERROR_FINDMETHOD). No counting is made
Result0-based count of substring occurences. 0 if not found

mdz_ansi Reference

mdz_ansi_copySubAnsi_async

Fills pSubAnsi with items from psAnsi, starting from nLeftPos and ending with one of pSeparators or nRightPos.

size_t mdz_ansi_copySubAnsi_async(const struct mdz_Ansi* psAnsi, size_t nLeftPos, size_t nRightPos, const char* pcSeparators, size_t nSeparatorsCount, struct mdz_Ansi* pSubAnsi, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_copySubAnsi(psAnsi, nLeftPos, nRightPos, pcSeparators, nSeparatorsCount, pSubAnsi);

ParameterDescription
psAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based start position to get items from. Use 0 to start from the beginning of string
nRightPos0-based end position to get items up to. Use Size-1 or SIZE_MAX to proceed till the end of string
pcSeparatorsseparators to get items up to
nSeparatorsCountnumber of separators or 0 if pcSeparators until 0-terminator should be used
pSubAnsipointer to string where items should be copied. Data in pSubAnsi will be re-reserved to appropriate size if necessary
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
SIZE_MAXif psAnsi == NULL, or pSubAnsi == NULL (MDZ_ERROR_SUBCONTAINER), or reallocation of m_pData in pSubAnsi was necessary but failed (MDZ_ERROR_ALLOCATION)
Sizeif pcSeparators == NULL (MDZ_ERROR_ITEMS), or nSeparatorsCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > nRightPos (MDZ_ERROR_BIGLEFT), or nRightPos >= Size (MDZ_ERROR_BIGRIGHT). No copying is made
Result0-based position after separator if found, or Size if not found

mdz_ansi Reference

mdz_ansi_copySubAnsiFrom_async

Fills pSubAnsi with items from psAnsi, starting from nLeftPos and containing nCount items.

size_t mdz_ansi_copySubAnsiFrom_async(const struct mdz_Ansi* psAnsi, size_t nLeftPos, size_t nCount, struct mdz_Ansi* pSubAnsi, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_ansi_copySubAnsiFrom(psAnsi, nLeftPos, nCount, pSubAnsi);

ParameterDescription
psAnsipointer to string returned by mdz_ansi_create() or mdz_ansi_create_attached()
nLeftPos0-based start position to get items from. Use 0 to start from the beginning of string
nCountnumber of items to copy or 0 if pcItems until 0-terminator should be used
pSubAnsipointer to string where items should be copied. Data in pSubAnsi will be re-reserved to appropriate size if necessary
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
SIZE_MAXif psAnsi == NULL, or pSubAnsi == NULL (MDZ_ERROR_SUBCONTAINER), or reallocation of m_pData in pSubAnsi was necessary but failed (MDZ_ERROR_ALLOCATION)
Sizeif nCount == 0 and pcItems[0] == 0 (MDZ_ERROR_ZEROCOUNT), or nCount is too big (MDZ_ERROR_BIGCOUNT), or nLeftPos + nCount > Size (MDZ_ERROR_BIGLEFT). No copying is made
Result0-based position after copied data, or Size if copied until the end of psAnsi

mdz_ansi Reference


mdz_utf8 API Reference is generated using mdzApiRefGenerator.

mdz_utf8 General Information and Functions

mdz_utf8 is dynamically-sized contiguous string, containing UTF-8 characters

If only ASCII/ANSI characters should be stored/processed - use mdz_ansi instead. It is much more speedy.

Capacity - how many bytes of memory is reserved.
Size - how many bytes are actually used in a string, excluding terminating 0.
Length - actual length of string in UTF-8 symbols, excluding terminating 0.

"reserve/AndReserve" functions allocate/reallocate memory dynamically using malloc()/realloc().
"attach" functionality allows attaching contiguous block of memory to string, for using string functions on it.

Unicode "combining characters" are not specially-distinguished and counted as a distinct symbols.

Init and destroy functions:

mdz_utf8_create
mdz_utf8_create_attached
mdz_utf8_destroy
mdz_utf8_clear
mdz_utf8_attachData

Reserve capacity functions:

mdz_utf8_reserve
mdz_utf8_capacity
mdz_utf8_size
mdz_utf8_length
mdz_utf8_offsetFromStart
mdz_utf8_isAttachedData
mdz_utf8_embedSize

Insert/remove functions:

mdz_utf8_insertUtf8_async
mdz_utf8_insertUtf8_string_async
mdz_utf8_insertAnsi_async
mdz_utf8_insertAnsi_string_async
mdz_utf8_insertWchar_async
mdz_utf8_insertWchar_string_async
mdz_utf8_insertUtf16_async
mdz_utf8_insertUtf16_string_async
mdz_utf8_insertUtf32_async
mdz_utf8_insertUtf32_string_async


mdz_utf8_create

Create empty UTF-8 string with Capacity == 1 (for 0-terminator), Size == 0 and Length == 0.

struct mdz_Utf8* mdz_utf8_create(size_t nEmbedSize);

ParameterDescription
nEmbedSizesize of "embedded part" of string. There is no "embedded part" if 0

ReturnDescription
NULLif library is not initialized with mdz_string_init() call
NULLif memory allocation failed
Resultpointer to string for use in other mdz_utf8 functions

mdz_utf8 Reference

mdz_utf8_create_attached

Create empty UTF-8 string with Capacity == 1 (for 0-terminator), Size == 0 and Length == 0.
Memory for utf8 structure starts at position pStart. Size of internal utf8 structure (it is usually bigger than mdz_Utf8!) is returned in pSize.

struct mdz_Utf8* mdz_utf8_create_attached(const void* pStart, size_t nAreaSizeBytes, size_t* pOutSize);

ParameterDescription
pStartmemory start position of utf8 structure
nAreaSizeBytessize of available memory from pStart in bytes. Should be large enough for internal utf8 structure
pOutSizereturned actual size of placed internal utf8 structure in bytes, may be NULL if not needed

ReturnDescription
NULLif library is not initialized with mdz_string_init() call
NULLif pStart == NULL or pSize == NULL
NULLif size in nSize is smaller than size of internal utf8 structure
Resultpointer to string for use in other mdz_utf8 functions. Normally it equals to pStart

mdz_utf8 Reference

mdz_utf8_destroy

Destroy UTF-8 string including underlying data.
If utf8 is attached using mdz_utf8_createAttached(), string controlling data will not be destroyed.
If utf8 data is attached using mdz_utf8_attachData(), m_pData will not be destroyed.

void mdz_utf8_destroy(const struct mdz_Utf8* pUtf8);

ParameterDescription
pUtf8pointer to string returned by mdz_utf8_create() or mdz_utf8_create_attached()

mdz_utf8 Reference

mdz_utf8_clear

Clear m_pData of UTF-8 string with setting Size in 0.

void mdz_utf8_clear(struct mdz_Utf8* pUtf8);

ParameterDescription
pUtf8pointer to string returned by mdz_utf8_create() or mdz_utf8_create_attached()

mdz_utf8 Reference

mdz_utf8_attachData

Attach pre-allocated data to UTF-8 string, assigning pData to m_pData. If attached, m_pData will not be destroyed in mdz_utf8_destroy()

mdz_bool mdz_utf8_attachData(struct mdz_Utf8* pUtf8, unsigned char* pData, size_t nOffsetFromStart, size_t nCapacity, enum mdz_attach_type enAttachType);

ParameterDescription
pUtf8pointer to string returned by mdz_utf8_create() or mdz_utf8_create_attached()
pDatapointer to pre-allocated data to attach
nOffsetFromStartposition in pre-allocated data to attach from. Can be > 0
nCapacityfull capacity pre-allocated data in items
enAttachTypetype of attachment. 0 is expected at position pData[nOffsetFromStart] if MDZ_ATTACH_ZEROSIZE. 0 is expected at position pData[nCapacity] if MDZ_ATTACH_SIZE_TERMINATOR. MDZ_ATTACH_SIZE_NO_TERMINATOR is not allowed

ReturnDescription
mdz_falseif pUtf8 == NULL
mdz_falseif pData == NULL (MDZ_ERROR_DATA), or nOffsetFromStart >= nCapacity (MDZ_ERROR_OFFSET), or invalid enAttachType (MDZ_ERROR_ATTACHTYPE)
mdz_falseif enAttachType is MDZ_ATTACH_ZEROSIZE or MDZ_ATTACH_SIZE_TERMINATOR but 0 is not found at expected position (MDZ_ERROR_ATTACH_TERMINATOR)
mdz_falseif enAttachType == MDZ_ATTACH_SIZE_TERMINATOR and pData contains invalid UTF-8 characters (MDZ_ERROR_CONTENT)
mdz_trueoperation succeeded

mdz_utf8 Reference

mdz_utf8_reserve

Reserve nNewCapacity bytes for UTF-8 string. String Size and Length do not change.

mdz_bool mdz_utf8_reserve(struct mdz_Utf8* pUtf8, size_t nNewCapacity);

ParameterDescription
pUtf8pointer to string returned by mdz_utf8_create() or mdz_utf8_create_attached()
nNewCapacitynew capacity in bytes to reserve

ReturnDescription
mdz_falseif pUtf8 == NULL
mdz_falseif memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_true reservation succeeded, or nNewCapacity <= Capacity (MDZ_ERROR_CAPACITY)

mdz_utf8 Reference

mdz_utf8_capacity

Return string Capacity in bytes.

size_t mdz_utf8_capacity(const struct mdz_Utf8* pUtf8);

ParameterDescription
pUtf8pointer to string returned by mdz_utf8_create()

ReturnDescription
SIZE_MAXif pUtf8 == NULL
Capacityotherwise

mdz_utf8 Reference

mdz_utf8_size

Return string Size in bytes.

size_t mdz_utf8_size(const struct mdz_Utf8* pUtf8);

ParameterDescription
pUtf8pointer to string returned by mdz_utf8_create() or mdz_utf8_create_attached()

ReturnDescription
SIZE_MAXif pUtf8 == NULL
Sizeotherwise

mdz_utf8 Reference

mdz_utf8_length

Return string Length in symbols.

size_t mdz_utf8_length(const struct mdz_Utf8* pUtf8);

ParameterDescription
pUtf8pointer to string returned by mdz_utf8_create() or mdz_utf8_create_attached()

ReturnDescription
SIZE_MAXif pUtf8 == NULL
Lengthotherwise

mdz_utf8 Reference

mdz_utf8_offsetFromStart

Return string OffsetFromStart in bytes.

size_t mdz_utf8_offsetFromStart(const struct mdz_Utf8* pUtf8);

ParameterDescription
pUtf8pointer to string returned by mdz_utf8_create() or mdz_utf8_create_attached()

ReturnDescription
SIZE_MAXif pUtf8 == NULL
OffsetFromStartotherwise

mdz_utf8 Reference

mdz_utf8_isAttachedData

Return if string data is attached.

mdz_bool mdz_utf8_isAttachedData(const struct mdz_Utf8* pUtf8);

ParameterDescription
pUtf8pointer to string returned by mdz_utf8_create() or mdz_utf8_create_attached()

ReturnDescription
mdz_falseif pUtf8 == NULL
mdz_falseif string data is not attached
mdz_trueif string data is attached

mdz_utf8 Reference

mdz_utf8_embedSize

Return string "embedded part" Size in bytes.

size_t mdz_utf8_embedSize(const struct mdz_Utf8* pUtf8);

ParameterDescription
pUtf8pointer to string returned by mdz_utf8_create() or mdz_utf8_create_attached()

ReturnDescription
SIZE_MAXif pUtf8 == NULL
Result"embedded part" Size otherwise

mdz_utf8 Reference

mdz_utf8_insertUtf8_async

Insert nCount UTF-8 bytes in string. Size grows on nCount. Length grows on symbols count.
String reserved area and pcItems should not overlap.

mdz_bool mdz_utf8_insertUtf8_async(struct mdz_Utf8* pUtf8, size_t nLeftPos, const unsigned char* pcItems, size_t nCount, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_utf8_insertUtf8(pUtf8, nLeftPos, pcItems, nCount, bReserve);

ParameterDescription
pUtf8pointer to string returned by mdz_utf8_create() or mdz_utf8_create_attached()
nLeftPos0-based position to insert in symbols. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pcItemsUTF-8 bytes to insert
nCountnumber of UTF-8 bytes to insert or 0 if pcItems until 0-terminator should be used
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pUtf8 == NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_utf8_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif pcItems contain invalid UTF-8 byte(s) (MDZ_ERROR_CONTENT)
mdz_falseif string reserved area and pcItems overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_utf8 Reference

mdz_utf8_insertUtf8_string_async

Insert UTF-8 string pUtf8Source in string. Size grows on nCount. Length grows on symbols count.
String reserved area and pUtf8Source->m_pData should not overlap.
This function performs significantly better than mdz_utf8_insertUtf8_async() - because there is no additional validation of inserted string.

mdz_bool mdz_utf8_insertUtf8_string_async(struct mdz_Utf8* pUtf8, size_t nLeftPos, const struct mdz_Utf8* pUtf8Source, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_utf8_insertUtf8_string(pUtf8, nLeftPos, pUtf8Source, bReserve);

ParameterDescription
pUtf8pointer to string returned by mdz_utf8_create() or mdz_utf8_create_attached()
nLeftPos0-based position to insert in symbols. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pUtf8Sourcepointer to UTF-8 string to insert. String is returned by mdz_utf8_create() or mdz_utf8_create_attached()
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pUtf8 == NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_utf8_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif string reserved area and pUtf8Source->m_pData overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pUtf8Source == NULL (MDZ_ERROR_SOURCE), or pUtf8Source.Size == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_utf8 Reference

mdz_utf8_insertAnsi_async

Insert nCount ASCII/ANSI bytes in string. Characters are converted to UTF-8 characters before isertion. Size grows on added bytes. Length grows on added symbols count.
String reserved area and pcItems should not overlap.

mdz_bool mdz_utf8_insertAnsi_async(struct mdz_Utf8* pUtf8, size_t nLeftPos, const unsigned char* pcItems, size_t nCount, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_utf8_insertAnsi(pUtf8, nLeftPos, pcItems, nCount, bReserve);

ParameterDescription
pUtf8pointer to string returned by mdz_utf8_create() or mdz_utf8_create_attached()
nLeftPos0-based position to insert in symbols. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pcItemsbytes to insert
nCountnumber of bytes to insert or 0 if pcItems until 0-terminator should be used
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pUtf8 == NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_utf8_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif string reserved area and pcItems overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_utf8 Reference

mdz_utf8_insertAnsi_string_async

Insert ASCII/ANSI string pAnsiSource in string. Characters are converted to UTF-8 characters before isertion. Size grows on added bytes. Length grows on added symbols count.
String reserved area and pAnsiSource->m_pData should not overlap.

mdz_bool mdz_utf8_insertAnsi_string_async(struct mdz_Utf8* pUtf8, size_t nLeftPos, const struct mdz_Ansi* pAnsiSource, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_utf8_insertAnsi_string(pUtf8, nLeftPos, pAnsiSource, bReserve);

ParameterDescription
pUtf8pointer to string returned by mdz_utf8_create() or mdz_utf8_create_attached()
nLeftPos0-based position to insert in symbols. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pAnsiSourcepointer to ASCII/ANSI string to insert. String is returned by mdz_ansi_create() or mdz_ansi_create_attached()
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pUtf8 == NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_utf8_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif string reserved area and pAnsiSource->m_pData overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pAnsiSource == NULL (MDZ_ERROR_SOURCE), or pAnsiSource.Size == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_utf8 Reference

mdz_utf8_insertWchar_async

Insert nCount "wide"-characters in string. Characters are converted to UTF-8 characters before isertion. Size grows on added bytes. Length grows on symbols count.
String reserved area and pwcItems should not overlap.

mdz_bool mdz_utf8_insertWchar_async(struct mdz_Utf8* pUtf8, size_t nLeftPos, const wchar_t* pwcItems, size_t nCount, size_t nWcharSize, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_utf8_insertWchar(pUtf8, nLeftPos, pwcItems, nCount, nWcharSize, bReserve);

ParameterDescription
pUtf8pointer to string returned by mdz_utf8_create() or mdz_utf8_create_attached()
nLeftPos0-based position to insert in symbols. "surrogate pairs" count as 1 symbol. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pwcItems"wide"-characters to insert
nCountnumber of "wide"-characters to insert or 0 if characters until 0-terminator should be used
nWcharSizesize of pwcItems wchar_t character in bytes
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pUtf8 == NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif nWcharSize is not 2 or 4 (MDZ_ERROR_WCHAR_SIZE)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_utf8_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif pwcItems contain invalid "wide"-character(s) (MDZ_ERROR_CONTENT)
mdz_falseif string reserved area and pwcItems overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pwcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_utf8 Reference

mdz_utf8_insertWchar_string_async

Insert "wide"-characters string pWcharSource in string. Characters are converted to UTF-8 characters before isertion. Size grows on added bytes. Length grows on symbols count.
String reserved area and pWcharSource->m_pData should not overlap.
For 2-bytes "wide"-characters - see information concerning Unicode "surrogate pairs"/"combining characters" in description of mdz_utf8_insertUtf16_async().
For 4-bytes "wide"-characters - see information concerning Unicode "combining characters" in description of mdz_utf8_insertUtf32_async().

mdz_bool mdz_utf8_insertWchar_string_async(struct mdz_Utf8* pUtf8, size_t nLeftPos, const struct mdz_Wchar* pWcharSource, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_utf8_insertWchar_string(pUtf8, nLeftPos, pWcharSource, bReserve);

ParameterDescription
pUtf8pointer to string returned by mdz_utf8_create() or mdz_utf8_create_attached()
nLeftPos0-based position to insert in symbols. "surrogate pairs" count as 1 symbol. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pWcharSourcepointer to "wide"-characters string to insert. String is returned by mdz_wchar_create() or mdz_wchar_create_attached()
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pUtf8 == NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_utf8_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif string reserved area and pWcharSource->m_pData overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pWcharSource == NULL (MDZ_ERROR_SOURCE), or pWcharSource.Size == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_utf8 Reference

mdz_utf8_insertUtf16_async

Insert nCount UTF-16 characters in string. UTF-16 characters are converted to UTF-8 before isertion. Size grows on added bytes. Length grows on symbols count.
String reserved area and pItems should not overlap.
UTF-16 "surrogate pairs" are supported and counted as 1 symbol (4 bytes size).
UTF-16 "combining characters" are not specially-distinguished and counted as a separate UTF-8 symbol.

mdz_bool mdz_utf8_insertUtf16_async(struct mdz_Utf8* pUtf8, size_t nLeftPos, const uint16_t* pItems, size_t nCount, enum mdz_endianness enEndianness, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_utf8_insertUtf16(pUtf8, nLeftPos, pItems, nCount, enEndianness, bReserve);

ParameterDescription
pUtf8pointer to string returned by mdz_utf8_create() or mdz_utf8_create_attached()
nLeftPos0-based position to insert in symbols. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pItemsUTF-16 characters to insert
nCountnumber of UTF-16 characters to insert or 0 if pcItems until 0-terminator should be used
enEndiannessendianness of UTF-16 characters in pItems. Can be MDZ_ENDIAN_LITTLE for "little-endian" or MDZ_ENDIAN_BIG for "big-endian"
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pUtf8 == NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_utf8_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif pItems contain invalid UTF-16 character(s) (MDZ_ERROR_CONTENT), or invalid enEndianness (MDZ_ERROR_ENDIANNESS)
mdz_falseif string reserved area and pItems overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_utf8 Reference

mdz_utf8_insertUtf16_string_async

Insert UTF-16 string pUtf16Source in string. UTF-16 characters are converted to UTF-8 before isertion. Size grows on added bytes. Length grows on symbols count.
String reserved area and pUtf16Source->m_pData should not overlap.
UTF-16 "surrogate pairs" are supported and counted as 1 symbol (4 bytes size).
UTF-16 "combining characters" are not specially-distinguished and counted as a separate UTF-8 symbol.

mdz_bool mdz_utf8_insertUtf16_string_async(struct mdz_Utf8* pUtf8, size_t nLeftPos, const struct mdz_Utf16* pUtf16Source, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_utf8_insertUtf16_string(pUtf8, nLeftPos, pUtf16Source, bReserve);

ParameterDescription
pUtf8pointer to string returned by mdz_utf8_create() or mdz_utf8_create_attached()
nLeftPos0-based position to insert in symbols. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pUtf16Sourcepointer to UTF16 string to insert. String is returned by mdz_utf16_create() or mdz_utf16_create_attached()
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pUtf8 == NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_utf8_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif string reserved area and pUtf16Source->m_pData overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pUtf16Source == NULL (MDZ_ERROR_SOURCE), or pUtf16Source.Size == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_utf8 Reference

mdz_utf8_insertUtf32_async

Insert nCount UTF-32 characters in string. UTF-32 characters are converted to UTF-8 before isertion. Size grows on added bytes. Length grows on symbols count.
String reserved area and pItems should not overlap.
Unicode "combining characters" are not specially-distinguished and counted as a separate UTF-8 symbol.

mdz_bool mdz_utf8_insertUtf32_async(struct mdz_Utf8* pUtf8, size_t nLeftPos, const uint32_t* pItems, size_t nCount, enum mdz_endianness enEndianness, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_utf8_insertUtf32(pUtf8, nLeftPos, pItems, nCount, enEndianness, bReserve);

ParameterDescription
pUtf8pointer to string returned by mdz_utf8_create() or mdz_utf8_create_attached()
nLeftPos0-based position to insert in symbols. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pItemsUTF-32 characters to insert
nCountnumber of UTF-32 characters to insert or 0 if pcItems until 0-terminator should be used
enEndiannessendianness of UTF-32 characters in pItems. Can be MDZ_ENDIAN_LITTLE for "little-endian" or MDZ_ENDIAN_BIG for "big-endian"
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pUtf8 == NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_utf8_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif string reserved area and pItems overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_utf8 Reference

mdz_utf8_insertUtf32_string_async

Insert UTF-32 string pUtf32Source in string. UTF-32 characters are converted to UTF-8 before isertion. Size grows on added bytes. Length grows on symbols count.
String reserved area and pUtf32Source->m_pData should not overlap.
Unicode "combining characters" are not specially-distinguished and counted as a separate UTF-8 symbol.

mdz_bool mdz_utf8_insertUtf32_string_async(struct mdz_Utf8* pUtf8, size_t nLeftPos, const struct mdz_Utf32* pUtf32Source, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_utf8_insertUtf32_string(pUtf8, nLeftPos, pUtf32Source, bReserve);

ParameterDescription
pUtf8pointer to string returned by mdz_utf8_create() or mdz_utf8_create_attached()
nLeftPos0-based position to insert in symbols. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pUtf32Sourcepointer to UTF-32 string to insert. String is returned by mdz_utf32_create() or mdz_utf32_create_attached()
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pUtf8 == NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_utf8_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif string reserved area and pUtf32Source->m_pData overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pUtf32Source == NULL (MDZ_ERROR_SOURCE), or pUtf32Source.Size == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_utf8 Reference


mdz_wchar API Reference is generated using mdzApiRefGenerator.

mdz_wchar General Information and Functions

mdz_wchar is dynamically-sized contiguous string, containing C wchar_t characters.

Capacity - how many "wide"-characters memory is reserved for.
Size - how many "wide"-characters are actually used in a string, excluding terminating 0.
Length - actual length of string in symbols, excluding terminating 0. "surrogate pairs" count as 1 symbol.
"reserve/AndReserve" functions allocate/reallocate memory dynamically using malloc()/realloc().
"attach" functionality allows attaching contiguous block of memory to string, for using string functions on it.

UTF-16 "surrogate pairs" are supported and checked.
Unicode "combining characters" are not specially-distinguished and counted as distinct symbols.
Endianness of bytes in "wide"-character - is always endianness of platform.
Size of wchar_t in bytes - is compiler-dependend. At the moment, library supports only wchar_t with size of 2 or 4 bytes.

Init and destroy functions:

mdz_wchar_create
mdz_wchar_create_attached
mdz_wchar_destroy
mdz_wchar_clear
mdz_wchar_attachData

Reserve capacity functions:

mdz_wchar_reserve
mdz_wchar_capacity
mdz_wchar_size
mdz_wchar_length
mdz_wchar_sizeof
mdz_wchar_offsetFromStart
mdz_wchar_isAttachedData
mdz_wchar_embedSize

Insert/remove functions:

mdz_wchar_insertWchar_async
mdz_wchar_insertWchar_string_async
mdz_wchar_insertAnsi_async
mdz_wchar_insertAnsi_string_async
mdz_wchar_insertUtf8_async
mdz_wchar_insertUtf8_string_async
mdz_wchar_insertUtf16_async
mdz_wchar_insertUtf16_string_async
mdz_wchar_insertUtf32_async
mdz_wchar_insertUtf32_string_async


mdz_wchar_create

Create empty "wide"-character string with Capacity == 1 (for 0-terminator), Size == 0 and Length == 0.

struct mdz_Wchar* mdz_wchar_create(size_t nEmbedSize);

ParameterDescription
nEmbedSizesize of "embedded part" of string. There is no "embedded part" if 0

ReturnDescription
NULLif library is not initialized with mdz_string_init() call
NULLif memory allocation failed
NULLif sizeof(wchar_t) != 2 (see description in file header)
Resultpointer to string for use in other mdz_wchar functions

mdz_wchar Reference

mdz_wchar_create_attached

Create empty "wide"-character string with Capacity == 1 (for 0-terminator), Size == 0 and Length == 0.
Memory for wchar structure starts at position pStart. Size of internal wchar structure (it is usually bigger than mdz_Wchar!) is returned in pSize.

struct mdz_Wchar* mdz_wchar_create_attached(const void* pStart, size_t nAreaSizeBytes, size_t* pOutSize);

ParameterDescription
pStartmemory start position of wchar structure
nAreaSizeBytessize of available memory from pStart in bytes. Should be large enough for internal wchar structure
pOutSizereturned actual size of allocated internal wchar structure in bytes, may be NULL if not needed

ReturnDescription
NULLif library is not initialized with mdz_string_init() call
NULLif sizeof(wchar_t) != 2 and sizeof(wchar_t) != 4 (see description in file header)
NULLif pStart == NULL or pSize == NULL
NULLif size in nSize is smaller than size of internal wchar structure
Resultpointer to string for use in other mdz_wchar functions. Normally it equals to pStart

mdz_wchar Reference

mdz_wchar_destroy

Destroy "wide"-character string including underlying data.
If wchar is attached using mdz_wchar_createAttached(), string controlling data will not be destroyed.
If wchar data is attached using mdz_wchar_attachData(), m_pData will not be destroyed.

void mdz_wchar_destroy(const struct mdz_Wchar* pWchar);

ParameterDescription
pWcharpointer to string returned by mdz_wchar_create() or mdz_wchar_create_attached()

mdz_wchar Reference

mdz_wchar_clear

Clear m_pData of "wide"-character string with setting Size in 0.

void mdz_wchar_clear(struct mdz_Wchar* pWchar);

ParameterDescription
pWcharpointer to string returned by mdz_wchar_create()

mdz_wchar Reference

mdz_wchar_attachData

Attach pre-allocated data to string, assigning pData to m_pData. If attached, m_pData will not be destroyed in mdz_wchar_destroy()

mdz_bool mdz_wchar_attachData(struct mdz_Wchar* pWchar, wchar_t* pData, size_t nOffsetFromStart, size_t nCapacity, enum mdz_attach_type enAttachType);

ParameterDescription
pWcharpointer to string returned by mdz_wchar_create() or mdz_wchar_create_attached()
pDatapointer to pre-allocated data to attach
nOffsetFromStartposition in pre-allocated data to attach from. Can be > 0
nCapacityfull capacity pre-allocated data in items
enAttachTypetype of attachment. 0 is expected at position pData[nOffsetFromStart] if MDZ_ATTACH_ZEROSIZE. 0 is expected at position pData[nCapacity] if MDZ_ATTACH_SIZE_TERMINATOR. MDZ_ATTACH_SIZE_NO_TERMINATOR is not allowed

ReturnDescription
mdz_falseif pWchar == NULL
mdz_falseif pData == NULL (MDZ_ERROR_DATA), or nOffsetFromStart >= nCapacity (MDZ_ERROR_OFFSET), or invalid enAttachType (MDZ_ERROR_ATTACHTYPE)
mdz_falseif enAttachType is MDZ_ATTACH_ZEROSIZE or MDZ_ATTACH_SIZE_TERMINATOR but 0 is not found at expected position (MDZ_ERROR_ATTACH_TERMINATOR)
mdz_falseif enAttachType == MDZ_ATTACH_SIZE_TERMINATOR and pData contains invalid "wide"-characters (MDZ_ERROR_CONTENT)
mdz_trueoperation succeeded

mdz_wchar Reference

mdz_wchar_reserve

Reserve nNewCapacity bytes for string. Size and Length do not change.

mdz_bool mdz_wchar_reserve(struct mdz_Wchar* pWchar, size_t nNewCapacity);

ParameterDescription
pWcharpointer to string returned by mdz_wchar_create() or mdz_wchar_create_attached()
nNewCapacitynew capacity in "wide"-characters to reserve

ReturnDescription
mdz_falseif pWchar == NULL
mdz_falseif memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_true reservation succeeded, or nNewCapacity <= Capacity (MDZ_ERROR_CAPACITY)

mdz_wchar Reference

mdz_wchar_capacity

Return string Capacity in "wide"-characters.

size_t mdz_wchar_capacity(const struct mdz_Wchar* pWchar);

ParameterDescription
pWcharpointer to string returned by mdz_wchar_create() or mdz_wchar_create_attached()

ReturnDescription
SIZE_MAXif pWchar == NULL
Capacityotherwise

mdz_wchar Reference

mdz_wchar_size

Return string Size in "wide"-characters.

size_t mdz_wchar_size(const struct mdz_Wchar* pWchar);

ParameterDescription
pWcharpointer to string returned by mdz_wchar_create() or mdz_wchar_create_attached()

ReturnDescription
SIZE_MAXif pWchar == NULL
Sizeotherwise

mdz_wchar Reference

mdz_wchar_length

Return string Length in symbols.

size_t mdz_wchar_length(const struct mdz_Wchar* pWchar);

ParameterDescription
pWcharpointer to string returned by mdz_wchar_create() or mdz_wchar_create_attached()

ReturnDescription
SIZE_MAXif pWchar == NULL
Lengthotherwise

mdz_wchar Reference

mdz_wchar_sizeof

Return sizeof(wchar_t) of string in bytes.

size_t mdz_wchar_sizeof(const struct mdz_Wchar* pWchar);

ParameterDescription
pWcharpointer to string returned by mdz_wchar_create() or mdz_wchar_create_attached()

ReturnDescription
SIZE_MAXif pWchar == NULL
sizeof(wchar_t) in bytesotherwise

mdz_wchar Reference

mdz_wchar_offsetFromStart

Return string OffsetFromStart in "wide"-characters.

size_t mdz_wchar_offsetFromStart(const struct mdz_Wchar* pWchar);

ParameterDescription
pWcharpointer to string returned by mdz_wchar_create() or mdz_wchar_create_attached()

ReturnDescription
SIZE_MAXif pWchar == NULL
OffsetFromStartotherwise

mdz_wchar Reference

mdz_wchar_isAttachedData

Return if string data is attached.

mdz_bool mdz_wchar_isAttachedData(const struct mdz_Wchar* pWchar);

ParameterDescription
pWcharpointer to string returned by mdz_wchar_create() or mdz_wchar_create_attached()

ReturnDescription
mdz_falseif pWchar == NULL
mdz_falseif string data is not attached
mdz_trueif string data is attached

mdz_wchar Reference

mdz_wchar_embedSize

Return string "embedded part" Size in "wide" characters.

size_t mdz_wchar_embedSize(const struct mdz_Wchar* pWchar);

ParameterDescription
pWcharpointer to string returned by mdz_wchar_create() or mdz_wchar_create_attached()

ReturnDescription
SIZE_MAXif pWchar == NULL
Result"embedded part" Size otherwise

mdz_wchar Reference

mdz_wchar_insertWchar_async

Insert nCount "wide"-characters pwcItems in string. Size grows on nCount. Length grows on symbols count.
String reserved area and pwcItems should not overlap.

mdz_bool mdz_wchar_insertWchar_async(struct mdz_Wchar* pWchar, size_t nLeftPos, const wchar_t* pwcItems, size_t nCount, size_t nWcharSize, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_wchar_insertWchar(pWchar, nLeftPos, pwcItems, nCount, nWcharSize, bReserve);

ParameterDescription
pWcharpointer to string returned by mdz_wchar_create() or mdz_wchar_create_attached()
nLeftPos0-based position to insert in symbols. "surrogate pairs" count as 1 symbol. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pwcItems"wide"-characters to insert
nCountnumber of "wide"-characters to insert
nWcharSizesize of pwcItems wchar_t character in bytes
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pWchar == NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif nWcharSize is not 2 or 4 (MDZ_ERROR_WCHAR_SIZE)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_wchar_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif pwcItems contain invalid "wide"-character(s) (MDZ_ERROR_CONTENT)
mdz_falseif string reserved area and pwcItems overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pwcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_wchar Reference

mdz_wchar_insertWchar_string_async

Insert "wide"-characters string pWcharSource in string. Size grows on nCount. Length grows on symbols count.
String reserved area and pWcharSource->m_pData should not overlap.

mdz_bool mdz_wchar_insertWchar_string_async(struct mdz_Wchar* pWchar, size_t nLeftPos, const struct mdz_Wchar* pWcharSource, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_wchar_insertWchar_string(pWchar, nLeftPos, pWcharSource, bReserve);

ParameterDescription
pWcharpointer to string returned by mdz_wchar_create() or mdz_wchar_create_attached()
nLeftPos0-based position to insert in symbols. "surrogate pairs" count as 1 symbol. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pWcharSourcepointer to "wide"-characters string to insert. String is returned by mdz_wchar_create() or mdz_wchar_create_attached()
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pWchar == NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_wchar_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif string reserved area and pWcharSource->m_pData overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pWcharSource == NULL (MDZ_ERROR_SOURCE), or pWcharSource.Size == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_wchar Reference

mdz_wchar_insertAnsi_async

Insert nCount ASCII/ANSI bytes in string. Characters are converted to "wide"-characters before isertion. Size grows on added "wide"-characters count. Length grows on added symbols count.
String reserved area and pcItems should not overlap.

mdz_bool mdz_wchar_insertAnsi_async(struct mdz_Wchar* pWchar, size_t nLeftPos, const unsigned char* pcItems, size_t nCount, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_wchar_insertAnsi(pWchar, nLeftPos, pcItems, nCount, bReserve);

ParameterDescription
pWcharpointer to string returned by mdz_wchar_create() or mdz_wchar_create_attached()
nLeftPos0-based position to insert in symbols. "surrogate pairs" count as 1 symbol. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pcItemsbytes to insert
nCountnumber of bytes to insert
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pWchar is NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_wchar_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif string reserved area and pcItems overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_wchar Reference

mdz_wchar_insertAnsi_string_async

Insert ASCII/ANSI string pAnsiSource in string. Characters are converted to "wide"-characters before isertion. Size grows on added "wide"-characters count. Length grows on added symbols count.
String reserved area and pAnsiSource->m_pData should not overlap.

mdz_bool mdz_wchar_insertAnsi_string_async(struct mdz_Wchar* pWchar, size_t nLeftPos, const struct mdz_Ansi* pAnsiSource, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_wchar_insertAnsi_string(pWchar, nLeftPos, pAnsiSource, bReserve);

ParameterDescription
pWcharpointer to string returned by mdz_wchar_create() or mdz_wchar_create_attached()
nLeftPos0-based position to insert in symbols. "surrogate pairs" count as 1 symbol. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pAnsiSourcepointer to ASCII/ANSI string to insert. String is returned by mdz_ansi_create() or mdz_ansi_create_attached()
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pWchar is NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_wchar_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif string reserved area and pAnsiSource->m_pData overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pAnsiSource == NULL (MDZ_ERROR_SOURCE), or pAnsiSource.Size == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_wchar Reference

mdz_wchar_insertUtf8_async

Insert nCount UTF-8 characters in string. UTF-8 characters are converted to "wide"-characters before isertion. Size grows on added "wide"-characters count. Length grows on added symbols count.
String reserved area and pcItems should not overlap.

mdz_bool mdz_wchar_insertUtf8_async(struct mdz_Wchar* pWchar, size_t nLeftPos, const unsigned char* pcItems, size_t nCount, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_wchar_insertUtf8(pWchar, nLeftPos, pcItems, nCount, bReserve);

ParameterDescription
pWcharpointer to string returned by mdz_wchar_create() or mdz_wchar_create_attached()
nLeftPos0-based position to insert in symbols. "surrogate pairs" count as 1 symbol. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pcItemsUTF-8 characters to insert
nCountnumber of UTF-8 characters to insert in bytes
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pWchar is NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_wchar_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif pcItems contain invalid UTF-8 character(s) (MDZ_ERROR_CONTENT)
mdz_falseif string reserved area and pcItems overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_wchar Reference

mdz_wchar_insertUtf8_string_async

Insert UTF-8 string pUtf8Source in string. UTF-8 characters are converted to "wide"-characters before isertion. Size grows on added "wide"-characters count. Length grows on added symbols count.
String reserved area and pUtf8Source->m_pData should not overlap.

mdz_bool mdz_wchar_insertUtf8_string_async(struct mdz_Wchar* pWchar, size_t nLeftPos, const struct mdz_Utf8* pUtf8Source, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_wchar_insertUtf8_string(pWchar, nLeftPos, pUtf8Source, bReserve);

ParameterDescription
pWcharpointer to string returned by mdz_wchar_create() or mdz_wchar_create_attached()
nLeftPos0-based position to insert in symbols. "surrogate pairs" count as 1 symbol. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pUtf8Sourcepointer to UTF-8 string to insert. String is returned by mdz_utf8_create() or mdz_utf8_create_attached()
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pWchar is NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_wchar_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif string reserved area and pUtf8Source->m_pData overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pUtf8Source == NULL (MDZ_ERROR_SOURCE), or pUtf8Source.Size == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_wchar Reference

mdz_wchar_insertUtf16_async

Insert nCount UTF-16 characters in string. UTF-16 characters are converted to "wide"-characters before isertion. Size grows on added "wide"-characters count. Length grows on added symbols count.
String reserved area and pItems should not overlap.

mdz_bool mdz_wchar_insertUtf16_async(struct mdz_Wchar* pWchar, size_t nLeftPos, const uint16_t* pItems, size_t nCount, enum mdz_endianness enEndianness, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_wchar_insertUtf16(pWchar, nLeftPos, pItems, nCount, enEndianness, bReserve);

ParameterDescription
pWcharpointer to string returned by mdz_wchar_create() or mdz_wchar_create_attached()
nLeftPos0-based position to insert in symbols. "surrogate pairs" count as 1 symbol. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pItemsUTF-16 characters to insert
nCountnumber of UTF-16 characters to insert
enEndiannessendianness of UTF-16 characters in pItems. Can be MDZ_ENDIAN_LITTLE for "little-endian" or MDZ_ENDIAN_BIG for "big-endian"
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pWchar is NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_wchar_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif pItems contain invalid UTF-16 character(s) (MDZ_ERROR_CONTENT), or invalid enEndianness (MDZ_ERROR_ENDIANNESS)
mdz_falseif string reserved area and pItems overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_wchar Reference

mdz_wchar_insertUtf16_string_async

Insert UTF-16 string pUtf16Source in string. UTF-16 characters are converted to "wide"-characters before isertion. Size grows on added "wide"-characters count. Length grows on added symbols count.
String reserved area and pUtf16Source->m_pData should not overlap.

mdz_bool mdz_wchar_insertUtf16_string_async(struct mdz_Wchar* pWchar, size_t nLeftPos, const struct mdz_Utf16* pUtf16Source, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_wchar_insertUtf16_string(pWchar, nLeftPos, pUtf16Source, bReserve);

ParameterDescription
pWcharpointer to string returned by mdz_wchar_create() or mdz_wchar_create_attached()
nLeftPos0-based position to insert in symbols. "surrogate pairs" count as 1 symbol. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pUtf16Sourcepointer to UTF-16 string to insert. String is returned by mdz_utf16_create() or mdz_utf16_create_attached()
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pWchar is NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_wchar_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif string reserved area and pUtf16Source->m_pData overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pUtf16Source == NULL (MDZ_ERROR_SOURCE), or pUtf16Source.Size == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_wchar Reference

mdz_wchar_insertUtf32_async

Insert nCount UTF-32 characters in string. UTF-32 characters are converted to "wide"-characters before isertion. Size grows on added "wide"-characters count. Length grows on added symbols count.
String reserved area and pItems should not overlap.

mdz_bool mdz_wchar_insertUtf32_async(struct mdz_Wchar* pWchar, size_t nLeftPos, const uint32_t* pItems, size_t nCount, enum mdz_endianness enEndianness, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_wchar_insertUtf32(pWchar, nLeftPos, pItems, nCount, enEndianness, bReserve);

ParameterDescription
pWcharpointer to string returned by mdz_wchar_create() or mdz_wchar_create_attached()
nLeftPos0-based position to insert in symbols. "surrogate pairs" count as 1 symbol. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pItemsUTF-32 characters to insert
nCountnumber of UTF-32 characters to insert
enEndiannessendianness of UTF-32 characters in pItems. Can be MDZ_ENDIAN_LITTLE for "little-endian" or MDZ_ENDIAN_BIG for "big-endian"
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pWchar is NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_wchar_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif pItems contain invalid UTF-32 character(s) (MDZ_ERROR_CONTENT), or invalid enEndianness (MDZ_ERROR_ENDIANNESS)
mdz_falseif string reserved area and pItems overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_wchar Reference

mdz_wchar_insertUtf32_string_async

Insert UTF-32 string pUtf32Source in string. UTF-32 characters are converted to "wide"-characters before isertion. Size grows on added "wide"-characters count. Length grows on added symbols count.
String reserved area and pUtf32Source->m_pData should not overlap.

mdz_bool mdz_wchar_insertUtf32_string_async(struct mdz_Wchar* pWchar, size_t nLeftPos, const struct mdz_Utf32* pUtf32Source, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_wchar_insertUtf32_string(pWchar, nLeftPos, pUtf32Source, bReserve);

ParameterDescription
pWcharpointer to string returned by mdz_wchar_create() or mdz_wchar_create_attached()
nLeftPos0-based position to insert in symbols. "surrogate pairs" count as 1 symbol. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pUtf32Sourcepointer to UTF-32 string to insert. String is returned by mdz_utf32_create() or mdz_utf32_create_attached()
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pWchar is NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_wchar_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif string reserved area and pUtf32Source->m_pData overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pUtf32Source == NULL (MDZ_ERROR_SOURCE), or pUtf32Source.Size == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_wchar Reference


mdz_utf16 API Reference is generated using mdzApiRefGenerator.

mdz_utf16 General Information and Functions

mdz_utf16 is dynamically-sized contiguous string, containing UTF-16 characters.

Capacity - how many UTF-16 characters memory is reserved for.
Size - how many UTF-16 characters are actually used in a string, excluding terminating 0.
Length - actual length of string in symbols, excluding terminating 0. "surrogate pairs" count as 1 symbol.

"reserve/AndReserve" functions allocate/reallocate memory dynamically using malloc()/realloc().
"attach" functionality allows attaching contiguous block of memory to string, for using string functions on it.

UTF-16 "surrogate pairs" are supported and checked
Unicode "combining characters" are not specially-distinguished and counted as distinct symbols
Endianness of bytes in UTF-16 character - is defined by m_enEndianness and set using enEndianness during string-creation in mdz_utf16_create()

Init and destroy functions:

mdz_utf16_create
mdz_utf16_create_attached
mdz_utf16_destroy
mdz_utf16_clear
mdz_utf16_attachData

Reserve capacity functions:

mdz_utf16_reserve
mdz_utf16_capacity
mdz_utf16_size
mdz_utf16_length
mdz_utf16_endianness
mdz_utf16_offsetFromStart
mdz_utf16_isAttachedData
mdz_utf16_embedSize

Insert/remove functions:

mdz_utf16_insertUtf16_async
mdz_utf16_insertUtf16_string_async
mdz_utf16_insertAnsi_async
mdz_utf16_insertAnsi_string_async
mdz_utf16_insertWchar_async
mdz_utf16_insertWchar_string_async
mdz_utf16_insertUtf8_async
mdz_utf16_insertUtf8_string_async
mdz_utf16_insertUtf32_async
mdz_utf16_insertUtf32_string_async


mdz_utf16_create

Create empty UTF-16 string with Capacity == 1 (for 0-terminator), Size == 0 and Length == 0.

struct mdz_Utf16* mdz_utf16_create(size_t nEmbedSize, enum mdz_endianness enEndianness);

ParameterDescription
nEmbedSizesize of "embedded part" of string. There is no "embedded part" if 0
enEndiannessendianness of string. Should be MDZ_ENDIAN_LITTLE or MDZ_ENDIAN_BIG

ReturnDescription
NULLif library is not initialized with mdz_string_init() call
NULLif memory allocation failed
NULLif invalid enEndianness
Resultpointer to string for use in other mdz_utf16 functions

mdz_utf16 Reference

mdz_utf16_create_attached

Create empty UTF-16 string with Capacity == 1 (for 0-terminator), Size == 0 and Length == 0.
Memory for utf16 structure starts at position pStart. Size of internal utf16 structure (it is usually bigger than mdz_Utf16!) is returned in pSize.

struct mdz_Utf16* mdz_utf16_create_attached(const void* pStart, enum mdz_endianness enEndianness, size_t nAreaSizeBytes, size_t* pOutSize);

ParameterDescription
pStartmemory start position of utf16 structure
enEndiannessendianness of string. Should be MDZ_ENDIAN_LITTLE or MDZ_ENDIAN_BIG
nAreaSizeBytessize of available memory from pStart in bytes. Should be large enough for internal utf16 structure
pOutSizereturned actual size of allocated internal utf16 structure in bytes, may be NULL if not needed

ReturnDescription
NULLif library is not initialized with mdz_string_init() call
NULLif invalid enEndianness
NULLif pStart == NULL or pSize == NULL
NULLif size in nSize is smaller than size of internal utf16 structure
Resultpointer to string for use in other mdz_utf16 functions. Normally it equals to pStart

mdz_utf16 Reference

mdz_utf16_destroy

Destroy UTF-16 string including underlying data.
If utf16 is attached using mdz_utf16_createAttached(), string controlling data will not be destroyed.
If utf16 data is attached using mdz_utf16_attachData(), m_pData will not be destroyed.

void mdz_utf16_destroy(const struct mdz_Utf16* pUtf16);

ParameterDescription
pUtf16pointer to string returned by mdz_utf16_create() or mdz_utf16_create_attached()

mdz_utf16 Reference

mdz_utf16_clear

Clear m_pData of UTF-16 string with setting Size in 0.

void mdz_utf16_clear(struct mdz_Utf16* pUtf16);

ParameterDescription
pUtf16pointer to string returned by mdz_utf16_create()

mdz_utf16 Reference

mdz_utf16_attachData

Attach pre-allocated data to UTF-16 string, assigning pData to m_pData. If attached, m_pData will not be destroyed in mdz_utf16_destroy()

mdz_bool mdz_utf16_attachData(struct mdz_Utf16* pUtf16, uint16_t* pData, size_t nOffsetFromStart, size_t nCapacity, enum mdz_attach_type enAttachType, enum mdz_endianness enEndianness);

ParameterDescription
pUtf16pointer to string returned by mdz_utf16_create() or mdz_utf16_create_attached()
pDatapointer to pre-allocated data to attach
nOffsetFromStartposition in pre-allocated data to attach from. Can be > 0
nCapacityfull capacity pre-allocated data in items
enAttachTypetype of attachment. 0 is expected at position pData[nOffsetFromStart] if MDZ_ATTACH_ZEROSIZE. 0 is expected at position pData[nCapacity] if MDZ_ATTACH_SIZE_TERMINATOR. MDZ_ATTACH_SIZE_NO_TERMINATOR is not allowed
enEndiannessendianness of UTF-16 characters in pData. Can be MDZ_ENDIAN_LITTLE for "little-endian" or MDZ_ENDIAN_BIG for "big-endian"

ReturnDescription
mdz_falseif pUtf16 == NULL
mdz_falseif pData == NULL (MDZ_ERROR_DATA), or nOffsetFromStart >= nCapacity (MDZ_ERROR_OFFSET), or invalid enAttachType (MDZ_ERROR_ATTACHTYPE), or invalid pData endianness (MDZ_ERROR_ENDIANNESS)
mdz_falseif enAttachType is MDZ_ATTACH_ZEROSIZE or MDZ_ATTACH_SIZE_TERMINATOR but 0 is not found at expected position (MDZ_ERROR_ATTACH_TERMINATOR)
mdz_falseif enAttachType == MDZ_ATTACH_SIZE_TERMINATOR and pData contains invalid UTF-16 characters (MDZ_ERROR_CONTENT)
mdz_trueoperation succeeded

mdz_utf16 Reference

mdz_utf16_reserve

Reserve nNewCapacity bytes for UTF-16 string. Size and Length do not change.

mdz_bool mdz_utf16_reserve(struct mdz_Utf16* pUtf16, size_t nNewCapacity);

ParameterDescription
pUtf16pointer to string returned by mdz_utf16_create() or mdz_utf16_create_attached()
nNewCapacitynew capacity in UTF-16 characters to reserve

ReturnDescription
mdz_falseif pUtf16 == NULL
mdz_falseif memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_true reservation succeeded, or nNewCapacity <= Capacity (MDZ_ERROR_CAPACITY)

mdz_utf16 Reference

mdz_utf16_capacity

Return string Capacity in UTF-16 characters.

size_t mdz_utf16_capacity(const struct mdz_Utf16* pUtf16);

ParameterDescription
pUtf16pointer to string returned by mdz_utf16_create() or mdz_utf16_create_attached()

ReturnDescription
SIZE_MAXif pUtf16 == NULL
Capacityotherwise

mdz_utf16 Reference

mdz_utf16_size

Return string Size in UTF-16 characters.

size_t mdz_utf16_size(const struct mdz_Utf16* pUtf16);

ParameterDescription
pUtf16pointer to string returned by mdz_utf16_create() or mdz_utf16_create_attached()

ReturnDescription
SIZE_MAXif pUtf16 == NULL
Sizeotherwise

mdz_utf16 Reference

mdz_utf16_length

Return string Length in symbols.

size_t mdz_utf16_length(const struct mdz_Utf16* pUtf16);

ParameterDescription
pUtf16pointer to string returned by mdz_utf16_create() or mdz_utf16_create_attached()

ReturnDescription
SIZE_MAXif pUtf16 == NULL
Lengthotherwise

mdz_utf16 Reference

mdz_utf16_endianness

Return string endianness.

enum mdz_endianness mdz_utf16_endianness(const struct mdz_Utf16* pUtf16);

ParameterDescription
pUtf16pointer to string returned by mdz_utf16_create() or mdz_utf16_create_attached()

ReturnDescription
MDZ_ENDIAN_ERRORif pUtf16 == NULL
Endiannessotherwise

mdz_utf16 Reference

mdz_utf16_offsetFromStart

Return string OffsetFromStart in UTF-16 characters.

size_t mdz_utf16_offsetFromStart(const struct mdz_Utf16* pUtf16);

ParameterDescription
pUtf16pointer to string returned by mdz_utf16_create() or mdz_utf16_create_attached()

ReturnDescription
SIZE_MAXif pUtf16 == NULL
OffsetFromStartotherwise

mdz_utf16 Reference

mdz_utf16_isAttachedData

Return if string data is attached.

mdz_bool mdz_utf16_isAttachedData(const struct mdz_Utf16* pUtf16);

ParameterDescription
pUtf16pointer to string returned by mdz_utf16_create() or mdz_utf16_create_attached()

ReturnDescription
mdz_falseif pUtf16 == NULL
mdz_falseif string data is not attached
mdz_trueif string data is attached

mdz_utf16 Reference

mdz_utf16_embedSize

Return string "embedded part" Size in UTF-16 characters.

size_t mdz_utf16_embedSize(const struct mdz_Utf16* pUtf16);

ParameterDescription
pUtf16pointer to string returned by mdz_utf16_create() or mdz_utf16_create_attached()

ReturnDescription
SIZE_MAXif pUtf16 == NULL
Result"embedded part" Size otherwise

mdz_utf16 Reference

mdz_utf16_insertUtf16_async

Insert nCount UTF-16 characters in string. Size grows on nCount. Length grows on symbols count.
String reserved area and pItems should not overlap.

mdz_bool mdz_utf16_insertUtf16_async(struct mdz_Utf16* pUtf16, size_t nLeftPos, const uint16_t* pItems, size_t nCount, enum mdz_endianness enEndianness, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_utf16_insertUtf16(pUtf16, nLeftPos, pItems, nCount, enEndianness, bReserve);

ParameterDescription
pUtf16pointer to string returned by mdz_utf16_create() or mdz_utf16_create_attached()
nLeftPos0-based position to insert in symbols. "surrogate pairs" count as 1 symbol. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pItemsUTF-16 characters to insert
nCountnumber of UTF-16 characters to insert or 0 if pcItems until 0-terminator should be used
enEndiannessendianness of UTF-16 characters in pItems. Can be MDZ_ENDIAN_LITTLE for "little-endian" or MDZ_ENDIAN_BIG for "big-endian"
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pUtf16 == NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_utf16_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif pItems contain invalid UTF-16 character(s) (MDZ_ERROR_CONTENT), or invalid enEndianness (MDZ_ERROR_ENDIANNESS)
mdz_falseif string reserved area and pItems overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_utf16 Reference

mdz_utf16_insertUtf16_string_async

Insert UTF-16 string pUtf16Source in string. Size grows on nCount. Length grows on symbols count.
String reserved area and pUtf16Source->m_pData should not overlap.
This function performs significantly better than mdz_utf16_insertUtf16_async() - because there is no additional validation of inserted string.

mdz_bool mdz_utf16_insertUtf16_string_async(struct mdz_Utf16* pUtf16, size_t nLeftPos, const struct mdz_Utf16* pUtf16Source, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_utf16_insertUtf16_string(pUtf16, nLeftPos, pUtf16Source, bReserve);

ParameterDescription
pUtf16pointer to string returned by mdz_utf16_create() or mdz_utf16_create_attached()
nLeftPos0-based position to insert in symbols. "surrogate pairs" count as 1 symbol. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pUtf16Sourcepointer to UTF-16 string to insert. String is returned by mdz_utf16_create() or mdz_utf16_create_attached()
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pUtf16 == NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_utf16_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif string reserved area and pUtf16Source->m_pData overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pUtf16Source == NULL (MDZ_ERROR_SOURCE), or pUtf16Source.Size == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_utf16 Reference

mdz_utf16_insertAnsi_async

Insert nCount ASCII/ANSI bytes in string. Characters are converted to UTF-16 characters before isertion. Size grows on added UTF-16 characters count. Length grows on added symbols count.
String reserved area and pcItems should not overlap.

mdz_bool mdz_utf16_insertAnsi_async(struct mdz_Utf16* pUtf16, size_t nLeftPos, const unsigned char* pcItems, size_t nCount, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_utf16_insertAnsi(pUtf16, nLeftPos, pcItems, nCount, bReserve);

ParameterDescription
pUtf16pointer to string returned by mdz_utf16_create() or mdz_utf16_create_attached()
nLeftPos0-based position to insert in symbols. "surrogate pairs" count as 1 symbol. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pcItemsbytes to insert
nCountnumber of bytes to insert or 0 if pcItems until 0-terminator should be used
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pUtf16 is NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_utf16_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif string reserved area and pcItems overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_utf16 Reference

mdz_utf16_insertAnsi_string_async

Insert ASCII/ANSI string pAnsiSource in string. Characters are converted to UTF-16 characters before isertion. Size grows on added UTF-16 characters count. Length grows on added symbols count.
String reserved area and pAnsiSource->m_pData should not overlap.

mdz_bool mdz_utf16_insertAnsi_string_async(struct mdz_Utf16* pUtf16, size_t nLeftPos, const struct mdz_Ansi* pAnsiSource, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_utf16_insertAnsi_string(pUtf16, nLeftPos, pAnsiSource, bReserve);

ParameterDescription
pUtf16pointer to string returned by mdz_utf16_create() or mdz_utf16_create_attached()
nLeftPos0-based position to insert in symbols. "surrogate pairs" count as 1 symbol. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pAnsiSourcepointer to ASCII/ANSI string to insert. String is returned by mdz_ansi_create() or mdz_ansi_create_attached()
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pUtf16 is NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_utf16_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif string reserved area and pAnsiSource->m_pData overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pAnsiSource == NULL (MDZ_ERROR_SOURCE), or pAnsiSource.Size == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_utf16 Reference

mdz_utf16_insertWchar_async

Insert nCount "wide"-characters in string. Characters are converted to UTF-16 characters before isertion. Size grows on added UTF-16 characters count. Length grows on added symbols count.
String reserved area and pwcItems should not overlap.

mdz_bool mdz_utf16_insertWchar_async(struct mdz_Utf16* pUtf16, size_t nLeftPos, const wchar_t* pwcItems, size_t nCount, size_t nWcharSize, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_utf16_insertWchar(pUtf16, nLeftPos, pwcItems, nCount, nWcharSize, bReserve);

ParameterDescription
pUtf16pointer to string returned by mdz_utf16_create() or mdz_utf16_create_attached()
nLeftPos0-based position to insert in symbols. "surrogate pairs" count as 1 symbol. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pwcItems"wide"-characters to insert
nCountnumber of "wide"-characters to insert or 0 if pcItems until 0-terminator should be used
nWcharSizesize of pwcItems wchar_t character in bytes
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pUtf16 is NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif nWcharSize is not 2 or 4 (MDZ_ERROR_WCHAR_SIZE)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_utf16_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif string reserved area and pwcItems overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_utf16 Reference

mdz_utf16_insertWchar_string_async

Insert "wide"-characters string pWcharSource in string. Characters are converted to UTF-16 characters before isertion. Size grows on added UTF-16 characters count. Length grows on added symbols count.
String reserved area and pWcharSource->m_pData should not overlap.
This function performs significantly better than mdz_utf16_insertWchar_async() - because there is no additional validation of inserted string.

mdz_bool mdz_utf16_insertWchar_string_async(struct mdz_Utf16* pUtf16, size_t nLeftPos, const struct mdz_Wchar* pWcharSource, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_utf16_insertWchar_string(pUtf16, nLeftPos, pWcharSource, bReserve);

ParameterDescription
pUtf16pointer to string returned by mdz_utf16_create() or mdz_utf16_create_attached()
nLeftPos0-based position to insert in symbols. "surrogate pairs" count as 1 symbol. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pWcharSourcepointer to "wide"-characters string to insert. String is returned by mdz_wchar_create() or mdz_wchar_create_attached()
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pUtf16 is NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_utf16_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif string reserved area and pWcharSource->m_pData overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pWcharSource == NULL (MDZ_ERROR_SOURCE), or pWcharSource.Size == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_utf16 Reference

mdz_utf16_insertUtf8_async

Insert nCount UTF-8 bytes in string. UTF-8 bytes are converted to UTF-16 characters before isertion. Size grows on added UTF-16 characters count. Length grows on added symbols count.
String reserved area and pcItems should not overlap.

mdz_bool mdz_utf16_insertUtf8_async(struct mdz_Utf16* pUtf16, size_t nLeftPos, const unsigned char* pcItems, size_t nCount, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_utf16_insertUtf8(pUtf16, nLeftPos, pcItems, nCount, bReserve);

ParameterDescription
pUtf16pointer to string returned by mdz_utf16_create() or mdz_utf16_create_attached()
nLeftPos0-based position to insert in symbols. "surrogate pairs" count as 1 symbol. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pcItemsUTF-8 characters to insert
nCountnumber of UTF-8 characters to insert in bytes or 0 if pcItems until 0-terminator should be used
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pUtf16 is NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_utf16_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif pcItems contain invalid UTF-8 byte(s) (MDZ_ERROR_CONTENT)
mdz_falseif string reserved area and pcItems overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_utf16 Reference

mdz_utf16_insertUtf8_string_async

Insert UTF-8 string pUtf8Source in string. UTF-8 bytes are converted to UTF-16 characters before isertion. Size grows on added UTF-16 characters count. Length grows on added symbols count.
String reserved area and pUtf8Source->m_pData should not overlap.

mdz_bool mdz_utf16_insertUtf8_string_async(struct mdz_Utf16* pUtf16, size_t nLeftPos, const struct mdz_Utf8* pUtf8Source, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_utf16_insertUtf8_string(pUtf16, nLeftPos, pUtf8Source, bReserve);

ParameterDescription
pUtf16pointer to string returned by mdz_utf16_create() or mdz_utf16_create_attached()
nLeftPos0-based position to insert in symbols. "surrogate pairs" count as 1 symbol. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pUtf8Sourcepointer to UTF-8 string to insert. String is returned by mdz_utf8_create() or mdz_utf8_create_attached()
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pUtf16 is NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_utf16_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif string reserved area and pUtf8Source->m_pData overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pUtf8Source == NULL (MDZ_ERROR_SOURCE), or pUtf8Source.Size == 0 (MDZ_ERROR_ZEROCOUNT), nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_utf16 Reference

mdz_utf16_insertUtf32_async

Insert nCount UTF-32 characters in string. UTF-32 characters are converted to UTF-16 characters before isertion. Size grows on added UTF-16 characters count. Length grows on added symbols count.
String reserved area and pItems should not overlap.

mdz_bool mdz_utf16_insertUtf32_async(struct mdz_Utf16* pUtf16, size_t nLeftPos, const uint32_t* pItems, size_t nCount, enum mdz_endianness enEndianness, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_utf16_insertUtf32(pUtf16, nLeftPos, pItems, nCount, enEndianness, bReserve);

ParameterDescription
pUtf16pointer to string returned by mdz_utf16_create() or mdz_utf16_create_attached()
nLeftPos0-based position to insert in symbols. "surrogate pairs" count as 1 symbol. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pItemsUTF-32 characters to insert
nCountnumber of UTF-32 characters to insert or 0 if pcItems until 0-terminator should be used
enEndiannessendianness of UTF-32 characters in pItems. Can be MDZ_ENDIAN_LITTLE for "little-endian" or MDZ_ENDIAN_BIG for "big-endian"
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pUtf16 is NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_utf16_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif pItems contain invalid UTF-8 character(s) (MDZ_ERROR_CONTENT), or invalid enEndianness (MDZ_ERROR_ENDIANNESS)
mdz_falseif string reserved area and pItems overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_utf16 Reference

mdz_utf16_insertUtf32_string_async

Insert UTF-32 string pUtf32Source in string. UTF-32 characters are converted to UTF-16 characters before isertion. Size grows on added UTF-16 characters count. Length grows on added symbols count.
String reserved area and pUtf32Source->m_pData should not overlap.

mdz_bool mdz_utf16_insertUtf32_string_async(struct mdz_Utf16* pUtf16, size_t nLeftPos, const struct mdz_Utf32* pUtf32Source, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_utf16_insertUtf32_string(pUtf16, nLeftPos, pUtf32Source, bReserve);

ParameterDescription
pUtf16pointer to string returned by mdz_utf16_create() or mdz_utf16_create_attached()
nLeftPos0-based position to insert in symbols. "surrogate pairs" count as 1 symbol. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pUtf32Sourcepointer to UTF-32 string to insert. String is returned by mdz_utf32_create() or mdz_utf32_create_attached()
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pUtf16 is NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_utf16_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif string reserved area and pUtf32Source->m_pData overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pUtf32Source == NULL (MDZ_ERROR_SOURCE), or pUtf32Source.Size == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_utf16 Reference


mdz_utf32 API Reference is generated using mdzApiRefGenerator.

mdz_utf32 General Information and Functions

mdz_utf32 is dynamically-sized contiguous string, containing UTF-32 characters.

Capacity - how many UTF-32 characters memory is reserved for.
Size - how many UTF-32 characters are actually used in a string, excluding terminating 0.
Length - actual length of string in symbols, excluding terminating 0.

"reserve/AndReserve" functions allocate/reallocate memory dynamically using malloc()/realloc().
"attach" functionality allows attaching contiguous block of memory to string, for using string functions on it.

Unicode "combining characters" are not specially-distinguished and counted as distinct symbols
Endianness of bytes in UTF-32 character - is defined by m_enEndianness and set using enEndianness during string-creation in mdz_utf32_create()

Init and destroy functions:

mdz_utf32_create
mdz_utf32_create_attached
mdz_utf32_destroy
mdz_utf32_clear
mdz_utf32_attachData

Reserve capacity functions:

mdz_utf32_reserve
mdz_utf32_capacity
mdz_utf32_size
mdz_utf32_length
mdz_utf32_endianness
mdz_utf32_offsetFromStart
mdz_utf32_isAttachedData
mdz_utf32_embedSize

Insert/remove functions:

mdz_utf32_insertUtf32_async
mdz_utf32_insertUtf32_string_async
mdz_utf32_insertAnsi_async
mdz_utf32_insertAnsi_string_async
mdz_utf32_insertWchar_async
mdz_utf32_insertWchar_string_async
mdz_utf32_insertUtf8_async
mdz_utf32_insertUtf8_string_async
mdz_utf32_insertUtf16_async
mdz_utf32_insertUtf16_string_async


mdz_utf32_create

Create empty UTF-32 string with Capacity == 1 (for 0-terminator), Size == 0 and Length == 0.

struct mdz_Utf32* mdz_utf32_create(size_t nEmbedSize, enum mdz_endianness enEndianness);

ParameterDescription
nEmbedSizesize of "embedded part" of string. There is no "embedded part" if 0
enEndiannessendianness of string. Should be MDZ_ENDIAN_LITTLE or MDZ_ENDIAN_BIG

ReturnDescription
NULLif library is not initialized with mdz_string_init() call
NULLif memory allocation failed
NULLif invalid enEndianness
Resultpointer to string for use in other mdz_utf32 functions

mdz_utf32 Reference

mdz_utf32_create_attached

Create empty UTF-32 string with Capacity == 1 (for 0-terminator), Size == 0 and Length == 0.
Memory for utf32 structure starts at position pStart. Size of internal utf32 structure (it is usually bigger than mdz_Utf32!) is returned in pSize.

struct mdz_Utf32* mdz_utf32_create_attached(const void* pStart, enum mdz_endianness enEndianness, size_t nAreaSizeBytes, size_t* pOutSize);

ParameterDescription
pStartmemory start position of utf32 structure
enEndiannessendianness of string. Should be MDZ_ENDIAN_LITTLE or MDZ_ENDIAN_BIG
nAreaSizeBytessize of available memory from pStart in bytes. Should be large enough for internal utf32 structure
pOutSizereturned actual size of allocated internal utf32 structure in bytes, may be NULL if not needed

ReturnDescription
NULLif library is not initialized with mdz_string_init() call
NULLif invalid enEndianness
NULLif pStart == NULL or pSize == NULL
NULLif size in nSize is smaller than size of internal utf32 structure
Resultpointer to string for use in other mdz_utf32 functions. Normally it equals to pStart

mdz_utf32 Reference

mdz_utf32_destroy

Destroy UTF-32 string including underlying data.
If utf32 is attached using mdz_utf32_createAttached(), string controlling data will not be destroyed.
If utf32 data is attached using mdz_utf32_attachData(), m_pData will not be destroyed.

void mdz_utf32_destroy(const struct mdz_Utf32* pUtf32);

ParameterDescription
pUtf32pointer to string returned by mdz_utf32_create() or mdz_utf32_create_attached()

mdz_utf32 Reference

mdz_utf32_clear

Clear m_pData of UTF-32 string with setting Size in 0.

void mdz_utf32_clear(struct mdz_Utf32* pUtf32);

ParameterDescription
pUtf32pointer to string returned by mdz_utf32_create()

mdz_utf32 Reference

mdz_utf32_attachData

Attach pre-allocated data to UTF-32 string, assigning pData to m_pData. If attached, m_pData will not be destroyed in mdz_utf32_destroy()

mdz_bool mdz_utf32_attachData(struct mdz_Utf32* pUtf32, uint32_t* pData, size_t nOffsetFromStart, size_t nCapacity, enum mdz_attach_type enAttachType, enum mdz_endianness enEndianness);

ParameterDescription
pUtf32pointer to string returned by mdz_utf32_create() or mdz_utf32_create_attached()
pDatapointer to pre-allocated data to attach
nOffsetFromStartposition in pre-allocated data to attach from. Can be > 0
nCapacityfull capacity pre-allocated data in items
enAttachTypetype of attachment. 0 is expected at position pData[nOffsetFromStart] if MDZ_ATTACH_ZEROSIZE. 0 is expected at position pData[nCapacity] if MDZ_ATTACH_SIZE_TERMINATOR. MDZ_ATTACH_SIZE_NO_TERMINATOR is not allowed
enEndiannessendianness of UTF-32 characters in pData. Can be MDZ_ENDIAN_LITTLE for "little-endian" or MDZ_ENDIAN_BIG for "big-endian"

ReturnDescription
mdz_falseif pUtf32 == NULL
mdz_falseif pData == NULL (MDZ_ERROR_DATA), or nOffsetFromStart >= nCapacity (MDZ_ERROR_OFFSET), or invalid enAttachType (MDZ_ERROR_ATTACHTYPE), or invalid pData endianness (MDZ_ERROR_ENDIANNESS)
mdz_falseif enAttachType is MDZ_ATTACH_ZEROSIZE or MDZ_ATTACH_SIZE_TERMINATOR but 0 is not found at expected position (MDZ_ERROR_ATTACH_TERMINATOR)
mdz_trueoperation succeeded

mdz_utf32 Reference

mdz_utf32_reserve

Reserve nNewCapacity bytes for UTF-32 string. Size and Length do not change.

mdz_bool mdz_utf32_reserve(struct mdz_Utf32* pUtf32, size_t nNewCapacity);

ParameterDescription
pUtf32pointer to string returned by mdz_utf32_create() or mdz_utf32_create_attached()
nNewCapacitynew capacity in UTF-32 characters to reserve

ReturnDescription
mdz_falseif pUtf32 == NULL
mdz_falseif memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_true reservation succeeded, or nNewCapacity <= Capacity (MDZ_ERROR_CAPACITY)

mdz_utf32 Reference

mdz_utf32_capacity

Return string Capacity in UTF-32 characters.

size_t mdz_utf32_capacity(const struct mdz_Utf32* pUtf32);

ParameterDescription
pUtf32pointer to string returned by mdz_utf32_create() or mdz_utf32_create_attached()

ReturnDescription
SIZE_MAXif pUtf32 == NULL
Capacityotherwise

mdz_utf32 Reference

mdz_utf32_size

Return string Size in UTF-32 characters.

size_t mdz_utf32_size(const struct mdz_Utf32* pUtf32);

ParameterDescription
pUtf32pointer to string returned by mdz_utf32_create() or mdz_utf32_create_attached()

ReturnDescription
SIZE_MAXif pUtf32 == NULL
Sizeotherwise

mdz_utf32 Reference

mdz_utf32_length

Return string length in symbols.

size_t mdz_utf32_length(const struct mdz_Utf32* pUtf32);

ParameterDescription
pUtf32pointer to string returned by mdz_utf32_create() or mdz_utf32_create_attached()

ReturnDescription
SIZE_MAXif pUtf32 == NULL
Sizeotherwise

mdz_utf32 Reference

mdz_utf32_endianness

Return string endianness.

enum mdz_endianness mdz_utf32_endianness(const struct mdz_Utf32* pUtf32);

ParameterDescription
pUtf32pointer to string returned by mdz_utf32_create() or mdz_utf32_create_attached()

ReturnDescription
MDZ_ENDIAN_ERRORif pUtf32 == NULL
Endiannessotherwise

mdz_utf32 Reference

mdz_utf32_offsetFromStart

Return string OffsetFromStart in UTF-32 characters.

size_t mdz_utf32_offsetFromStart(const struct mdz_Utf32* pUtf32);

ParameterDescription
pUtf32pointer to string returned by mdz_utf32_create() or mdz_utf32_create_attached()

ReturnDescription
SIZE_MAXif pUtf32 == NULL
OffsetFromStartotherwise

mdz_utf32 Reference

mdz_utf32_isAttachedData

Return if string data is attached.

mdz_bool mdz_utf32_isAttachedData(const struct mdz_Utf32* pUtf32);

ParameterDescription
pUtf32pointer to string returned by mdz_utf32_create() or mdz_utf32_create_attached()

ReturnDescription
mdz_falseif pUtf32 == NULL
mdz_falseif string data is not attached
mdz_trueif string data is attached

mdz_utf32 Reference

mdz_utf32_embedSize

Return string "embedded part" Size in UTF-32 characters.

size_t mdz_utf32_embedSize(const struct mdz_Utf32* pUtf32);

ParameterDescription
pUtf32pointer to string returned by mdz_utf32_create() or mdz_utf32_create_attached()

ReturnDescription
SIZE_MAXif pUtf32 == NULL
Result"embedded part" Size otherwise

mdz_utf32 Reference

mdz_utf32_insertUtf32_async

Insert nCount UTF-32 characters in string. Size grows on nCount. Length grows on symbols count.
String reserved area and pItems should not overlap.

mdz_bool mdz_utf32_insertUtf32_async(struct mdz_Utf32* pUtf32, size_t nLeftPos, const uint32_t* pItems, size_t nCount, enum mdz_endianness enEndianness, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_utf32_insertUtf32(pUtf32, nLeftPos, pItems, nCount, enEndianness, bReserve);

ParameterDescription
pUtf32pointer to string returned by mdz_utf32_create() or mdz_utf32_create_attached()
nLeftPos0-based position to insert in symbols. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pItemsUTF-32 characters to insert
nCountnumber of UTF-32 characters to insert or 0 if pcItems until 0-terminator should be used
enEndiannessendianness of UTF-32 characters in pItems. Can be MDZ_ENDIAN_LITTLE for "little-endian" or MDZ_ENDIAN_BIG for "big-endian"
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pUtf32 == NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_utf32_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif string reserved area and pItems overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_utf32 Reference

mdz_utf32_insertUtf32_string_async

Insert UTF-32 string pUtf32Source in string. Size grows on nCount. Length grows on symbols count.
String reserved area and pUtf32Source->m_pData should not overlap.
This function performs significantly better than mdz_utf32_insertUtf32_async() - because there is no additional validation of inserted string.

mdz_bool mdz_utf32_insertUtf32_string_async(struct mdz_Utf32* pUtf32, size_t nLeftPos, const struct mdz_Utf32* pUtf32Source, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_utf32_insertUtf32_string(pUtf32, nLeftPos, pUtf32Source, bReserve);

ParameterDescription
pUtf32pointer to string returned by mdz_utf32_create() or mdz_utf32_create_attached()
nLeftPos0-based position to insert in symbols. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pUtf32Sourcepointer to UTF-32 string to insert. String is returned by mdz_utf32_create() or mdz_utf32_create_attached()
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pUtf32 == NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_utf32_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif invalid enEndianness (MDZ_ERROR_ENDIANNESS)
mdz_falseif string reserved area and pUtf32Source->m_pData overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pUtf32Source == NULL (MDZ_ERROR_SOURCE), or pUtf32Source.Size == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_utf32 Reference

mdz_utf32_insertAnsi_async

Insert nCount ASCII/ANSI bytes in string. Characters are converted to UTF-32 characters before isertion. Size grows on added UTF-32 characters count. Length grows on added symbols count.
String reserved area and pcItems should not overlap.

mdz_bool mdz_utf32_insertAnsi_async(struct mdz_Utf32* pUtf32, size_t nLeftPos, const unsigned char* pcItems, size_t nCount, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_utf32_insertAnsi(pUtf32, nLeftPos, pcItems, nCount, bReserve);

ParameterDescription
pUtf32pointer to string returned by mdz_utf32_create() or mdz_utf32_create_attached()
nLeftPos0-based position to insert in symbols. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pcItemsbytes to insert
nCountnumber of bytes to insert or 0 if pcItems until 0-terminator should be used
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pUtf32 is NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_utf32_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif string reserved area and pcItems overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_utf32 Reference

mdz_utf32_insertAnsi_string_async

Insert ASCII/ANSI string pAnsiSource in string. Characters are converted to UTF-32 characters before isertion. Size grows on added UTF-32 characters count. Length grows on added symbols count.
String reserved area and pAnsiSource->m_pData should not overlap.

mdz_bool mdz_utf32_insertAnsi_string_async(struct mdz_Utf32* pUtf32, size_t nLeftPos, const struct mdz_Ansi* pAnsiSource, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_utf32_insertAnsi_string(pUtf32, nLeftPos, pAnsiSource, bReserve);

ParameterDescription
pUtf32pointer to string returned by mdz_utf32_create() or mdz_utf32_create_attached()
nLeftPos0-based position to insert in symbols. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pAnsiSourcepointer to ASCII/ANSI string to insert. String is returned by mdz_ansi_create() or mdz_ansi_create_attached()
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pUtf32 is NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_utf32_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif string reserved area and pAnsiSource->m_pData overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pAnsiSource == NULL (MDZ_ERROR_SOURCE), or pAnsiSource.Size == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_utf32 Reference

mdz_utf32_insertWchar_async

Insert nCount "wide"-characters in string. Characters are converted to UTF-32 characters before isertion. Size grows on added UTF-32 characters count. Length grows on added symbols count.
String reserved area and pwcItems should not overlap.

mdz_bool mdz_utf32_insertWchar_async(struct mdz_Utf32* pUtf32, size_t nLeftPos, const wchar_t* pwcItems, size_t nCount, size_t nWcharSize, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_utf32_insertWchar(pUtf32, nLeftPos, pwcItems, nCount, nWcharSize, bReserve);

ParameterDescription
pUtf32pointer to string returned by mdz_utf32_create() or mdz_utf32_create_attached()
nLeftPos0-based position to insert in symbols symbols. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pwcItems"wide"-characters to insert
nCountnumber of characters to insert in bytes or 0 if pcItems until 0-terminator should be used
nWcharSizesize of pwcItems wchar_t character in bytes
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pUtf32 is NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif nWcharSize is not 2 or 4 (MDZ_ERROR_WCHAR_SIZE)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_utf32_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif string reserved area and pwcItems overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_utf32 Reference

mdz_utf32_insertWchar_string_async

Insert "wide"-characters string pWcharSource in string. Characters are converted to UTF-32 characters before isertion. Size grows on added UTF-32 characters count. Length grows on added symbols count.
String reserved area and pWcharSource->m_pData should not overlap.

mdz_bool mdz_utf32_insertWchar_string_async(struct mdz_Utf32* pUtf32, size_t nLeftPos, const struct mdz_Wchar* pWcharSource, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_utf32_insertWchar_string(pUtf32, nLeftPos, pWcharSource, bReserve);

ParameterDescription
pUtf32pointer to string returned by mdz_utf32_create() or mdz_utf32_create_attached()
nLeftPos0-based position to insert in symbols symbols. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pWcharSourcepointer to "wide"-characters string to insert. String is returned by mdz_wchar_create() or mdz_wchar_create_attached()
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pUtf32 is NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_utf32_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif string reserved area and pWcharSource->m_pData overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pWcharSource == NULL (MDZ_ERROR_SOURCE), or pWcharSource.Size == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_utf32 Reference

mdz_utf32_insertUtf8_async

Insert nCount UTF-8 characters in string. UTF-8 characters are converted to UTF-32 characters before isertion. Size grows on added UTF-32 characters count. Length grows on added symbols count.
String reserved area and pcItems should not overlap.

mdz_bool mdz_utf32_insertUtf8_async(struct mdz_Utf32* pUtf32, size_t nLeftPos, const unsigned char* pcItems, size_t nCount, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_utf32_insertUtf8(pUtf32, nLeftPos, pcItems, nCount, bReserve);

ParameterDescription
pUtf32pointer to string returned by mdz_utf32_create() or mdz_utf32_create_attached()
nLeftPos0-based position to insert in symbols. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pcItemsUTF-8 characters to insert
nCountnumber of UTF-8 characters to insert in bytes or 0 if pcItems until 0-terminator should be used
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pUtf32 is NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_utf32_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif pcItems contain invalid UTF-8 character(s) (MDZ_ERROR_CONTENT)
mdz_falseif string reserved area and pcItems overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pcItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_utf32 Reference

mdz_utf32_insertUtf8_string_async

Insert UTF-8 string pUtf8Source in string. UTF-8 characters are converted to UTF-32 characters before isertion. Size grows on added UTF-32 characters count. Length grows on added symbols count.
String reserved area and pUtf8Source->m_pData should not overlap.

mdz_bool mdz_utf32_insertUtf8_string_async(struct mdz_Utf32* pUtf32, size_t nLeftPos, const struct mdz_Utf8* pUtf8Source, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_utf32_insertUtf8_string(pUtf32, nLeftPos, pUtf8Source, bReserve);

ParameterDescription
pUtf32pointer to string returned by mdz_utf32_create() or mdz_utf32_create_attached()
nLeftPos0-based position to insert in symbols. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pUtf8Sourcepointer to UTF-8 string to insert. String is returned by mdz_utf8_create() or mdz_utf8_create_attached()
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pUtf32 is NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_utf32_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif string reserved area and pUtf8Source->m_pData overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pUtf8Source == NULL (MDZ_ERROR_SOURCE), or pUtf8Source.Size == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_utf32 Reference

mdz_utf32_insertUtf16_async

Insert nCount UTF-16 characters in string. Characters are converted to UTF-32 characters before isertion. Size grows on added UTF-32 characters count. Length grows on symbols count.
String reserved area and pItems should not overlap.

mdz_bool mdz_utf32_insertUtf16_async(struct mdz_Utf32* pUtf32, size_t nLeftPos, const uint16_t* pItems, size_t nCount, enum mdz_endianness enEndianness, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_utf32_insertUtf16(pUtf32, nLeftPos, pItems, nCount, enEndianness, bReserve);

ParameterDescription
pUtf32pointer to string returned by mdz_utf32_create() or mdz_utf32_create_attached()
nLeftPos0-based position to insert in symbols. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pItemsUTF-16 items to insert
nCountnumber of UTF-16 items to insert or 0 if pcItems until 0-terminator should be used
enEndiannessendianness of UTF-16 characters in pItems. Can be MDZ_ENDIAN_LITTLE for "little-endian" or MDZ_ENDIAN_BIG for "big-endian"
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pUtf32 == NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_utf32_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif pItems contain invalid 2-byte character(s) (MDZ_ERROR_CONTENT), or invalid enEndianness (MDZ_ERROR_ENDIANNESS)
mdz_falseif string reserved area and pItems overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_utf32 Reference

mdz_utf32_insertUtf16_string_async

Insert UTF-16 string pUtf16Source in string. Characters are converted to UTF-32 characters before isertion. Size grows on added UTF-32 characters count. Length grows on symbols count.
String reserved area and pUtf16Source->m_pData should not overlap.

mdz_bool mdz_utf32_insertUtf16_string_async(struct mdz_Utf32* pUtf32, size_t nLeftPos, const struct mdz_Utf16* pUtf16Source, mdz_bool bReserve, struct mdz_asyncData* pAsyncData);

Synchronous version:
mdz_utf32_insertUtf16_string(pUtf32, nLeftPos, pUtf16Source, bReserve);

ParameterDescription
pUtf32pointer to string returned by mdz_utf32_create() or mdz_utf32_create_attached()
nLeftPos0-based position to insert in symbols. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pUtf16Sourcepointer to UTF-16 string to insert. String is returned by mdz_utf16_create() or mdz_utf16_create_attached()
bReserveif mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncDatapointer to shared async data for asynchronous call, or NULL if call should be synchronous

ReturnDescription
mdz_falseif pUtf32 == NULL
mdz_falseif bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_falseif bReserve == mdz_true and there is not enough capacity for inserted data, but m_pData is attached using mdz_utf32_attachData() (MDZ_ERROR_ATTACHED)
mdz_falseif bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_falseif string reserved area and pUtf16Source->m_pData overlap (MDZ_ERROR_OVERLAP)
mdz_trueif pUtf16Source == NULL (MDZ_ERROR_SOURCE), or pUtf16Source.Size == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_trueinsertion succeeded

mdz_utf32 Reference
Software Development. Strive for the Impossible to achieve Excellence.
Copyright Ⓒ 2017 - 2024 maxdz Software GmbH. All rights reserved.
Site content is generated using mdzWebSiteGenerator