Skip to content

mdz_utf8_insertUtf16_async

Maksym Dzyubenko edited this page Feb 7, 2024 · 1 revision

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);

Parameter Description
pUtf8 pointer to string returned by mdz_utf8_create() or mdz_utf8_create_attached()
nLeftPos 0-based position to insert in symbols. If nLeftPos == Length or -1, items are appended. nLeftPos > Length is not allowed
pItems UTF-16 characters to insert
nCount number of UTF-16 characters to insert or 0 if pcItems until 0-terminator should be used
enEndianness endianness of UTF-16 characters in pItems. Can be MDZ_ENDIAN_LITTLE for "little-endian" or MDZ_ENDIAN_BIG for "big-endian"
bReserve if mdz_true reserve capacity when there is not enough space for insertion, otherwise mdz_false
pAsyncData pointer to shared async data for asynchronous call, or NULL if call should be synchronous
Return Description
mdz_false if pUtf8 == NULL
mdz_false if bReserve == mdz_true and memory allocation failed (MDZ_ERROR_ALLOCATION)
mdz_false if 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_false if bReserve == mdz_false and there is not enough free Capacity in the string (MDZ_ERROR_CAPACITY)
mdz_false if pItems contain invalid UTF-16 character(s) (MDZ_ERROR_CONTENT), or invalid enEndianness (MDZ_ERROR_ENDIANNESS)
mdz_false if string reserved area and pItems overlap (MDZ_ERROR_OVERLAP)
mdz_true if pItems == NULL (MDZ_ERROR_ITEMS), or nCount == 0 (MDZ_ERROR_ZEROCOUNT), or nLeftPos > Length (MDZ_ERROR_BIGLEFT). No insertion is made
mdz_true insertion succeeded
mdz_utf8 API Reference is generated using mdzApiRefGenerator.

mdz_string functions

mdz_ansi functions

mdz_utf8 functions

mdz_wchar functions

mdz_utf16 functions

mdz_utf32 functions

mdz_string API Reference is generated using mdzApiRefGenerator.
Clone this wiki locally