DDraceNetwork Docs
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
Strings

Functions

void str_append (char *dst, const char *src, int dst_size)
 
template<int N>
void str_append (char(&dst)[N], const char *src)
 
int str_copy (char *dst, const char *src, int dst_size)
 
template<int N>
void str_copy (char(&dst)[N], const char *src)
 
void str_utf8_truncate (char *dst, int dst_size, const char *src, int truncation_len)
 
void str_truncate (char *dst, int dst_size, const char *src, int truncation_len)
 
int str_length (const char *str)
 
int str_format_v (char *buffer, int buffer_size, const char *format, va_list args)
 
int str_format (char *buffer, int buffer_size, const char *format,...)
 
const char * str_trim_words (const char *str, int words)
 
bool str_has_cc (const char *str)
 
void str_sanitize_cc (char *str)
 
void str_sanitize (char *str)
 
void str_clean_whitespaces (char *str)
 
char * str_skip_to_whitespace (char *str)
 
const char * str_skip_to_whitespace_const (const char *str)
 
char * str_skip_whitespaces (char *str)
 
const char * str_skip_whitespaces_const (const char *str)
 
int str_comp_nocase (const char *a, const char *b)
 
int str_comp_nocase_num (const char *a, const char *b, int num)
 
int str_comp (const char *a, const char *b)
 
int str_comp_num (const char *a, const char *b, int num)
 
int str_comp_filenames (const char *a, const char *b)
 
const char * str_startswith_nocase (const char *str, const char *prefix)
 
const char * str_startswith (const char *str, const char *prefix)
 
const char * str_endswith_nocase (const char *str, const char *suffix)
 
int str_utf8_dist_buffer (const char *a, const char *b, int *buf, int buf_len)
 
int str_utf32_dist_buffer (const int *a, int a_len, const int *b, int b_len, int *buf, int buf_len)
 
const char * str_find_nocase (const char *haystack, const char *needle)
 
const char * str_find (const char *haystack, const char *needle)
 
bool str_delimiters_around_offset (const char *haystay, const char *delim, int offset, int *start, int *end)
 
const char * str_rchr (const char *haystack, char needle)
 
int str_countchr (const char *haystack, char needle)
 
void str_hex (char *dst, int dst_size, const void *data, int data_size)
 
void str_hex_cstyle (char *dst, int dst_size, const void *data, int data_size, int bytes_per_line=12)
 
int str_hex_decode (void *dst, int dst_size, const char *src)
 
void str_base64 (char *dst, int dst_size, const void *data, int data_size)
 
int str_base64_decode (void *dst, int dst_size, const char *data)
 
void str_timestamp (char *buffer, int buffer_size)
 
int str_isspace (char c)
 
int str_utf8_comp_confusable (const char *str1, const char *str2)
 
int str_utf8_tolower_codepoint (int code)
 
void str_utf8_tolower (const char *input, char *output, size_t size)
 
int str_utf8_comp_nocase (const char *a, const char *b)
 
int str_utf8_comp_nocase_num (const char *a, const char *b, int num)
 
const char * str_utf8_find_nocase (const char *haystack, const char *needle, const char **end=nullptr)
 
int str_utf8_isspace (int code)
 
int str_utf8_isstart (char c)
 
const char * str_utf8_skip_whitespaces (const char *str)
 
void str_utf8_trim_right (char *param)
 
int str_utf8_rewind (const char *str, int cursor)
 
int str_utf8_fix_truncation (char *str)
 
int str_utf8_forward (const char *str, int cursor)
 
int str_utf8_decode (const char **ptr)
 
int str_utf8_encode (char *ptr, int chr)
 
int str_utf8_check (const char *str)
 
void str_utf8_copy_num (char *dst, const char *src, int dst_size, int num)
 
void str_utf8_stats (const char *str, size_t max_size, size_t max_count, size_t *size, size_t *count)
 
size_t str_utf8_offset_bytes_to_chars (const char *str, size_t byte_offset)
 
size_t str_utf8_offset_chars_to_bytes (const char *str, size_t char_offset)
 
const char * str_next_token (const char *str, const char *delim, char *buffer, int buffer_size)
 

Detailed Description

String related functions.

Function Documentation

◆ str_append() [1/2]

void str_append ( char *  dst,
const char *  src,
int  dst_size 
)

Appends a string to another.

Parameters
dstPointer to a buffer that contains a string.
srcString to append.
dst_sizeSize of the buffer of the dst string.
Remarks
The strings are treated as null-terminated strings.
Guarantees that dst string will contain null-termination.

◆ str_append() [2/2]

template<int N>
void str_append ( char(&)  dst[N],
const char *  src 
)

Appends a string to a fixed-size array of chars.

Parameters
dstArray that shall receive the string.
srcString to append.
Remarks
The strings are treated as null-terminated strings.
Guarantees that dst string will contain null-termination.

◆ str_base64()

void str_base64 ( char *  dst,
int  dst_size,
const void *  data,
int  data_size 
)

Takes a datablock and generates the base64 encoding of it.

Parameters
dstBuffer to fill with base64 data.
dst_sizeSize of the buffer.
dataData to turn into base64.
dataSize of the data.
Remarks
The destination buffer will be null-terminated

◆ str_base64_decode()

int str_base64_decode ( void *  dst,
int  dst_size,
const char *  data 
)

Takes a base64 string without any whitespace and correct padding and returns a byte array.

Parameters
dstBuffer for the byte array.
dst_sizeSize of the buffer.
dataString to decode.
Returns
< 0 - Error.
<= 0 - Success, length of the resulting byte buffer.
Remarks
The contents of the buffer is only valid on success.

◆ str_clean_whitespaces()

void str_clean_whitespaces ( char *  str)

Removes leading and trailing spaces and limits the use of multiple spaces.

Parameters
strString to clean up.
Remarks
The strings are treated as null-terminated strings.

◆ str_comp()

int str_comp ( const char *  a,
const char *  b 
)

Compares two strings case sensitive.

Parameters
aString to compare.
bString to compare.
Returns
< 0 if string a is less than string b.
0 if string a is equal to string b.
> 0 if string a is greater than string b.
Remarks
The strings are treated as null-terminated strings.

◆ str_comp_filenames()

int str_comp_filenames ( const char *  a,
const char *  b 
)

Compares two strings case insensitive, digit chars will be compared as numbers.

Parameters
aString to compare.
bString to compare.
Returns
< 0 - String a is less than string b
0 - String a is equal to string b
> 0 - String a is greater than string b
Remarks
The strings are treated as null-terminated strings.

◆ str_comp_nocase()

int str_comp_nocase ( const char *  a,
const char *  b 
)

Compares to strings case insensitively.

Parameters
aString to compare.
bString to compare.
Returns
< 0 if string a is less than string b.
0 if string a is equal to string b.
> 0 if string a is greater than string b.
Remarks
Only guaranteed to work with a-z/A-Z.
The strings are treated as null-terminated strings.

◆ str_comp_nocase_num()

int str_comp_nocase_num ( const char *  a,
const char *  b,
int  num 
)

Compares up to num characters of two strings case insensitively.

Parameters
aString to compare.
bString to compare.
numMaximum characters to compare.
Returns
< 0 if string a is less than string b.
0 if string a is equal to string b.
> 0 if string a is greater than string b.
Remarks
Only guaranteed to work with a-z/A-Z.
Use str_utf8_comp_nocase_num for unicode support.
The strings are treated as null-terminated strings.

◆ str_comp_num()

int str_comp_num ( const char *  a,
const char *  b,
int  num 
)

Compares up to num characters of two strings case sensitive.

Parameters
aString to compare.
bString to compare.
numMaximum characters to compare.
Returns
< 0 if string a is less than string b.
0 if string a is equal to string b.
> 0 if string a is greater than string b.
Remarks
The strings are treated as null-terminated strings.

◆ str_copy() [1/2]

int str_copy ( char *  dst,
const char *  src,
int  dst_size 
)

Copies a string to another.

Parameters
dstPointer to a buffer that shall receive the string.
srcString to be copied.
dst_sizeSize of the buffer dst.
Returns
Length of written string, even if it has been truncated
Remarks
The strings are treated as null-terminated strings.
Guarantees that dst string will contain null-termination.

◆ str_copy() [2/2]

template<int N>
void str_copy ( char(&)  dst[N],
const char *  src 
)

Copies a string to a fixed-size array of chars.

Parameters
dstArray that shall receive the string.
srcString to be copied.
Remarks
The strings are treated as null-terminated strings.
Guarantees that dst string will contain null-termination.

◆ str_countchr()

int str_countchr ( const char *  haystack,
char  needle 
)

Counts the number of occurrences of a character in a string.

Parameters
haystackString to count in.
needleCharacter to count.
Returns
The number of characters in the haystack string matching the needle character.
Remarks
The strings are treated as null-terminated strings.
The number of zero-terminator characters cannot be counted.

◆ str_delimiters_around_offset()

bool str_delimiters_around_offset ( const char *  haystay,
const char *  delim,
int  offset,
int *  start,
int *  end 
)
Parameters
haystackString to search in.
delimString to search for.
offsetNumber of characters into haystack.
startWill be set to the first delimiter on the left side of the offset (or haystack start).
endWill be set to the first delimiter on the right side of the offset (or haystack end).
Returns
true if both delimiters were found.
false if a delimiter is missing (it uses haystack start and end as fallback).
Remarks
The strings are treated as null-terminated strings.

◆ str_endswith_nocase()

const char * str_endswith_nocase ( const char *  str,
const char *  suffix 
)

Checks case insensitive whether the string ends with a certain suffix.

Parameters
strString to check.
suffixSuffix to look.
Returns
A pointer to the beginning of the suffix in the string str.
nullptr if the string suffix isn't a suffix of the string str.
Remarks
The strings are treated as null-terminated strings.

◆ str_find()

const char * str_find ( const char *  haystack,
const char *  needle 
)

Finds a string inside another string case sensitive.

Parameters
haystackString to search in.
needleString to search for.
Returns
A pointer into haystack where the needle was found.
Returns nullptr if needle could not be found.
Remarks
The strings are treated as null-terminated strings.

◆ str_find_nocase()

const char * str_find_nocase ( const char *  haystack,
const char *  needle 
)

Finds a string inside another string case insensitively.

Parameters
haystackString to search in.
needleString to search for.
Returns
A pointer into haystack where the needle was found.
Returns nullptr if needle could not be found.
Remarks
Only guaranteed to work with a-z/A-Z.
Use str_utf8_find_nocase for unicode support.
The strings are treated as null-terminated strings.

◆ str_format()

int str_format ( char *  buffer,
int  buffer_size,
const char *  format,
  ... 
)

Performs printf formatting into a buffer.

Parameters
bufferPointer to the buffer to receive the formatted string.
buffer_sizeSize of the buffer.
formatprintf formatting string.
...Parameters for the formatting.
Returns
Length of written string, even if it has been truncated.
Remarks
See the C manual for syntax for the printf formatting string.
The strings are treated as null-terminated strings.
Guarantees that buffer string will contain null-termination.

◆ str_format_v()

int str_format_v ( char *  buffer,
int  buffer_size,
const char *  format,
va_list  args 
)

Performs printf formatting into a buffer.

Parameters
bufferPointer to the buffer to receive the formatted string.
buffer_sizeSize of the buffer.
formatprintf formatting string.
argsThe variable argument list.
Returns
Length of written string, even if it has been truncated.
Remarks
See the C manual for syntax for the printf formatting string.
The strings are treated as null-terminated strings.
Guarantees that buffer string will contain null-termination.

◆ str_has_cc()

bool str_has_cc ( const char *  str)

Check whether string has ASCII control characters.

Parameters
strString to check.
Returns
Whether the string has ASCII control characters.
Remarks
The strings are treated as null-terminated strings.

◆ str_hex()

void str_hex ( char *  dst,
int  dst_size,
const void *  data,
int  data_size 
)

Takes a datablock and generates a hex string of it, with spaces between bytes.

Parameters
dstBuffer to fill with hex data.
dst_sizeSize of the buffer (at least 3 * data_size + 1 to contain all data).
dataData to turn into hex.
data_sizeSize of the data.
Remarks
The destination buffer will be null-terminated.

◆ str_hex_cstyle()

void str_hex_cstyle ( char *  dst,
int  dst_size,
const void *  data,
int  data_size,
int  bytes_per_line = 12 
)

Takes a datablock and generates a hex string of it, in the C style array format, i.e. with bytes formatted in 0x00-0xFF notation and commas with spaces between the bytes. The output can be split over multiple lines by specifying the maximum number of bytes that should be printed per line.

Parameters
dstBuffer to fill with hex data.
dst_sizeSize of the buffer (at least 6 * data_size + 1 to contain all data).
dataData to turn into hex.
data_sizeSize of the data.
bytes_per_lineAfter this many printed bytes a newline will be printed.
Remarks
The destination buffer will be null-terminated.

◆ str_hex_decode()

int str_hex_decode ( void *  dst,
int  dst_size,
const char *  src 
)

Takes a hex string without spaces between bytes and returns a byte array.

Parameters
dstBuffer for the byte array.
dst_sizesize of the buffer.
dataString to decode.
Returns
2 if string doesn't exactly fit the buffer.
1 if invalid character in string.
0 if success.
Remarks
The contents of the buffer is only valid on success.

◆ str_isspace()

int str_isspace ( char  c)

Determines whether a character is whitespace.

Parameters
cthe character to check.
Returns
1 if the character is whitespace, 0 otherwise.
Remarks
The following characters are considered whitespace: ' ', '
', '\r', '\t'.

◆ str_length()

int str_length ( const char *  str)

Returns the length of a null-terminated string.

Parameters
strPointer to the string.
Returns
Length of string in bytes excluding the null-termination.

◆ str_next_token()

const char * str_next_token ( const char *  str,
const char *  delim,
char *  buffer,
int  buffer_size 
)

Writes the next token after str into buf, returns the rest of the string.

Parameters
strPointer to string.
delimDelimiter for tokenization.
bufferBuffer to store token in.
buffer_sizeSize of the buffer.
Returns
Pointer to rest of the string.
Remarks
The token is always null-terminated.

◆ str_rchr()

const char * str_rchr ( const char *  haystack,
char  needle 
)

Finds the last occurrence of a character

Parameters
haystackString to search in.
needleCharacter to search for.
Returns
A pointer into haystack where the needle was found.
Returns nullptr if needle could not be found.
Remarks
The strings are treated as null-terminated strings.
The zero-terminator character can also be found with this function.

◆ str_sanitize()

void str_sanitize ( char *  str)

Replaces all characters below 32 with whitespace with exception to \t,
and \r.

Parameters
strString to sanitize.
Remarks
The strings are treated as null-terminated strings.

◆ str_sanitize_cc()

void str_sanitize_cc ( char *  str)

Replaces all characters below 32 with whitespace.

Parameters
strString to sanitize.
Remarks
The strings are treated as null-terminated strings.

◆ str_skip_to_whitespace()

char * str_skip_to_whitespace ( char *  str)

Skips leading non-whitespace characters.

Parameters
strPointer to the string.
Returns
Pointer to the first whitespace character found within the string.
Remarks
The strings are treated as null-terminated strings.
Whitespace is defined according to str_isspace.

◆ str_skip_to_whitespace_const()

const char * str_skip_to_whitespace_const ( const char *  str)

◆ str_skip_whitespaces()

char * str_skip_whitespaces ( char *  str)

Skips leading whitespace characters.

Parameters
strPointer to the string.
Returns
Pointer to the first non-whitespace character found within the string.
Remarks
The strings are treated as null-terminated strings.
Whitespace is defined according to str_isspace.

◆ str_skip_whitespaces_const()

const char * str_skip_whitespaces_const ( const char *  str)

◆ str_startswith()

const char * str_startswith ( const char *  str,
const char *  prefix 
)

Checks case sensitive whether the string begins with a certain prefix.

Parameters
strString to check.
prefixPrefix to look for.
Returns
A pointer to the string str after the string prefix, or nullptr if the string prefix isn't a prefix of the string str.
Remarks
The strings are treated as null-terminated strings.

◆ str_startswith_nocase()

const char * str_startswith_nocase ( const char *  str,
const char *  prefix 
)

Checks case insensitive whether the string begins with a certain prefix.

Parameters
strString to check.
prefixPrefix to look for.
Returns
A pointer to the string str after the string prefix, or nullptr if the string prefix isn't a prefix of the string str.
Remarks
The strings are treated as null-terminated strings.

◆ str_timestamp()

void str_timestamp ( char *  buffer,
int  buffer_size 
)

Copies a timestamp in the format year-month-day_hour-minute-second to the string.

Parameters
bufferPointer to a buffer that shall receive the timestamp string.
buffer_sizeSize of the buffer.
Remarks
Guarantees that buffer string will contain null-termination.

◆ str_trim_words()

const char * str_trim_words ( const char *  str,
int  words 
)

Trims specific number of words at the start of a string.

Parameters
strString to trim the words from.
wordsCount of words to trim.
Returns
Trimmed string
Remarks
The strings are treated as null-terminated strings.
Leading whitespace is always trimmed.

◆ str_truncate()

void str_truncate ( char *  dst,
int  dst_size,
const char *  src,
int  truncation_len 
)

Truncates a string to a given length.

Parameters
dstPointer to a buffer that shall receive the string.
dst_sizeSize of the buffer dst.
srcString to be truncated.
truncation_lenMaximum length of the returned string (not counting the null-termination).
Remarks
The strings are treated as null-terminated strings.
Guarantees that dst string will contain null-termination.

◆ str_utf32_dist_buffer()

int str_utf32_dist_buffer ( const int *  a,
int  a_len,
const int *  b,
int  b_len,
int *  buf,
int  buf_len 
)

Computes the edit distance between two strings, allows buffers to be passed in.

Parameters
aFirst string for the edit distance.
a_lenLength of the first string.
bSecond string for the edit distance.
b_lenLength of the second string.
bufBuffer for the function.
buf_lenLength of the buffer, must be at least as long as the length of both strings combined plus two.
Returns
The edit distance between the both strings.
Remarks
The strings are treated as null-terminated strings.

◆ str_utf8_check()

int str_utf8_check ( const char *  str)

Checks if a strings contains just valid UTF-8 characters.

Parameters
strPointer to a possible UTF-8 string.
Returns
0 if invalid characters were found, 1 if only valid characters were found.
Remarks
The string is treated as null-terminated UTF-8 string.

◆ str_utf8_comp_confusable()

int str_utf8_comp_confusable ( const char *  str1,
const char *  str2 
)

Checks if two strings only differ by confusable characters.

Parameters
str1String to compare.
str2String to compare.
Returns
0 if the strings are confusables.

◆ str_utf8_comp_nocase()

int str_utf8_comp_nocase ( const char *  a,
const char *  b 
)

Compares two UTF-8 strings case insensitively.

Parameters
aString to compare.
bString to compare.
Returns
< 0 if string a is less than string b.
0 if string a is equal to string b.
> 0 if string a is greater than string b.

◆ str_utf8_comp_nocase_num()

int str_utf8_comp_nocase_num ( const char *  a,
const char *  b,
int  num 
)

Compares up to num bytes of two UTF-8 strings case insensitively.

Parameters
aString to compare.
bString to compare.
numMaximum bytes to compare.
Returns
< 0 if string a is less than string b.
0 if string a is equal to string b.
> 0 if string a is greater than string b.

◆ str_utf8_copy_num()

void str_utf8_copy_num ( char *  dst,
const char *  src,
int  dst_size,
int  num 
)

Copies a number of UTF-8 characters from one string to another.

Parameters
dstPointer to a buffer that shall receive the string.
srcString to be copied.
dst_sizeSize of the buffer dst.
numMaximum number of UTF-8 characters to be copied.
Remarks
The strings are treated as null-terminated strings.
Garantees that dst string will contain null-termination.

◆ str_utf8_decode()

int str_utf8_decode ( const char **  ptr)

Decodes a UTF-8 codepoint.

Parameters
ptrPointer to a UTF-8 string. This pointer will be moved forward.
Returns
The Unicode codepoint. -1 for invalid input and 0 for end of string.
Remarks
This function will also move the pointer forward.
You may call this function again after an error occurred.
The strings are treated as null-terminated.

◆ str_utf8_dist_buffer()

int str_utf8_dist_buffer ( const char *  a,
const char *  b,
int *  buf,
int  buf_len 
)

Computes the edit distance between two strings, allows buffers to be passed in.

Parameters
aFirst string for the edit distance.
bSecond string for the edit distance.
bufBuffer for the function.
buf_lenLength of the buffer, must be at least as long as twice the length of both strings combined plus two.
Returns
The edit distance between the both strings.
Remarks
The strings are treated as null-terminated strings.

◆ str_utf8_encode()

int str_utf8_encode ( char *  ptr,
int  chr 
)

Encode a UTF-8 character.

Parameters
ptrPointer to a buffer that should receive the data. Should be able to hold at least 4 bytes.
Returns
Number of bytes put into the buffer.
Remarks
Does not do null-termination of the string.

◆ str_utf8_find_nocase()

const char * str_utf8_find_nocase ( const char *  haystack,
const char *  needle,
const char **  end = nullptr 
)

Finds a UTF-8 string inside another UTF-8 string case insensitively.

Parameters
haystackString to search in.
needleString to search for.
endA pointer that will be set to a pointer into haystack directly behind the last character where the needle was found. Will be set to nullptrif needle could not be found. Optional parameter.
Returns
A pointer into haystack where the needle was found.
Returns nullptr if needle could not be found.
Remarks
The strings are treated as null-terminated strings.

◆ str_utf8_fix_truncation()

int str_utf8_fix_truncation ( char *  str)

Fixes truncation of a Unicode character at the end of a UTF-8 string.

Parameters
strUTF-8 string.
Returns
The new string length.
Remarks
The strings are treated as null-terminated.

◆ str_utf8_forward()

int str_utf8_forward ( const char *  str,
int  cursor 
)

Moves a cursor forwards in an UTF-8 string.

Parameters
strUTF-8 string.
cursorPosition in the string.
Returns
New cursor position.
Remarks
Won't move the cursor beyond the null-termination marker.
The strings are treated as null-terminated.

◆ str_utf8_isspace()

int str_utf8_isspace ( int  code)

Checks whether the given Unicode codepoint renders as space.

Parameters
codeUnicode codepoint to check.
Returns
Whether the codepoint is a space.

◆ str_utf8_isstart()

int str_utf8_isstart ( char  c)

Checks whether a given byte is the start of a UTF-8 character.

Parameters
cByte to check.
Returns
Whether the char starts a UTF-8 character.

◆ str_utf8_offset_bytes_to_chars()

size_t str_utf8_offset_bytes_to_chars ( const char *  str,
size_t  byte_offset 
)

Converts a byte offset of a UTF-8 string to the UTF-8 character offset.

Parameters
textPointer to the string.
byte_offsetOffset in bytes.
Returns
Offset in UTF-8 characters. Clamped to the maximum length of the string in UTF-8 characters.
Remarks
The string is treated as a null-terminated UTF-8 string.
It's the user's responsibility to make sure the bounds are aligned.

◆ str_utf8_offset_chars_to_bytes()

size_t str_utf8_offset_chars_to_bytes ( const char *  str,
size_t  char_offset 
)

Converts a UTF-8 character offset of a UTF-8 string to the byte offset.

Parameters
textPointer to the string.
char_offsetOffset in UTF-8 characters.
Returns
Offset in bytes. Clamped to the maximum length of the string in bytes.
Remarks
The string is treated as a null-terminated UTF-8 string.
It's the user's responsibility to make sure the bounds are aligned.

◆ str_utf8_rewind()

int str_utf8_rewind ( const char *  str,
int  cursor 
)

Moves a cursor backwards in an UTF-8 string,

Parameters
strUTF-8 string.
cursorPosition in the string.
Returns
New cursor position.
Remarks
Won't move the cursor less then 0.
The strings are treated as null-terminated.

◆ str_utf8_skip_whitespaces()

const char * str_utf8_skip_whitespaces ( const char *  str)

Skips leading characters that render as spaces.

Parameters
strInput string.
Returns
Pointer to the first non-whitespace character found within the string.
Remarks
The strings are treated as null-terminated strings.

◆ str_utf8_stats()

void str_utf8_stats ( const char *  str,
size_t  max_size,
size_t  max_count,
size_t *  size,
size_t *  count 
)

Determines the byte size and UTF-8 character count of a UTF-8 string.

Parameters
strPointer to the string.
max_sizeMaximum number of bytes to count.
max_countMaximum number of UTF-8 characters to count.
sizePointer to store size (number of non. Zero bytes) of the string.
countPointer to store count of UTF-8 characters of the string.
Remarks
The string is treated as null-terminated UTF-8 string.
It's the user's responsibility to make sure the bounds are aligned.

◆ str_utf8_tolower()

void str_utf8_tolower ( const char *  input,
char *  output,
size_t  size 
)

Converts the given UTF-8 string to lowercase (locale insensitive).

Parameters
strString to convert to lowercase.
outputBuffer that will receive the lowercase string.
sizeSize of the output buffer.
Remarks
The strings are treated as zero-terminated strings.
This function does not work in-place as converting a UTF-8 string to lowercase may increase its length.

◆ str_utf8_tolower_codepoint()

int str_utf8_tolower_codepoint ( int  code)

Converts the given Unicode codepoint to lowercase (locale insensitive).

Parameters
codeUnicode codepoint to convert.
Returns
Lowercase codepoint, or the original codepoint if there is no lowercase version.

◆ str_utf8_trim_right()

void str_utf8_trim_right ( char *  param)

Removes trailing characters that render as spaces by modifying the string in-place.

Parameters
paramInput string.
Remarks
The string is modified in-place.
The strings are treated as null-terminated.

◆ str_utf8_truncate()

void str_utf8_truncate ( char *  dst,
int  dst_size,
const char *  src,
int  truncation_len 
)

Truncates a UTF-8 encoded string to a given length.

Parameters
dstPointer to a buffer that shall receive the string.
dst_sizeSize of the buffer dst.
strString to be truncated.
truncation_lenMaximum codepoints in the returned string.
Remarks
The strings are treated as utf8-encoded null-terminated strings.
Guarantees that dst string will contain null-termination.