![]() |
DDraceNetwork Documentation
|
String related functions.
Appends a string to another.
| dst | Pointer to a buffer that contains a string. |
| src | String to append. |
| dst_size | Size of the buffer of the dst string. |
Appends a string to a fixed-size array of chars.
| dst | Array that shall receive the string. |
| src | String to append. |
Takes a datablock and generates the base64 encoding of it.
| dst | Buffer to fill with base64 data. |
| dst_size | Size of the buffer. |
| data | Data to turn into base64. |
| data | Size of the data. |
Takes a base64 string without any whitespace and correct padding and returns a byte array.
| dst | Buffer for the byte array. |
| dst_size | Size of the buffer. |
| data | String to decode. |
< 0 - Error. <= 0 - Success, length of the resulting byte buffer.Removes leading and trailing spaces and limits the use of multiple spaces.
| str | String to clean up. |
Compares two strings case sensitive.
| a | String to compare. |
| b | String to compare. |
< 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.Compares two strings case insensitive, digit chars will be compared as numbers.
| a | String to compare. |
| b | String to compare. |
< 0 - String a is less than string b 0 - String a is equal to string b > 0 - String a is greater than string bCompares to strings case insensitively.
| a | String to compare. |
| b | String to compare. |
< 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.Compares up to num characters of two strings case insensitively.
| a | String to compare. |
| b | String to compare. |
| num | Maximum characters to compare. |
< 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 for unicode support. Compares up to num characters of two strings case sensitive.
| a | String to compare. |
| b | String to compare. |
| num | Maximum characters to compare. |
< 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.Copies a string to another.
| dst | Pointer to a buffer that shall receive the string. |
| src | String to be copied. |
| dst_size | Size of the buffer dst. |
Copies a string to a fixed-size array of chars.
| dst | Array that shall receive the string. |
| src | String to be copied. |
Counts the number of occurrences of a character in a string.
| haystack | String to count in. |
| needle | Character to count. |
| bool str_delimiters_around_offset | ( | const char * | haystay, |
| const char * | delim, | ||
| int | offset, | ||
| int * | start, | ||
| int * | end | ||
| ) |
| haystack | String to search in. |
| delim | String to search for. |
| offset | Number of characters into haystack. |
| start | Will be set to the first delimiter on the left side of the offset (or haystack start). |
| end | Will be set to the first delimiter on the right side of the offset (or haystack end). |
true if both delimiters were found. false if a delimiter is missing (it uses haystack start and end as fallback).Checks case insensitive whether the string ends with a certain suffix.
| str | String to check. |
| suffix | Suffix to look. |
str. nullptr if the string suffix isn't a suffix of the string str.Finds a string inside another string case sensitive.
| haystack | String to search in. |
| needle | String to search for. |
haystack where the needle was found. nullptr if needle could not be found.Finds a string inside another string case insensitively.
| haystack | String to search in. |
| needle | String to search for. |
haystack where the needle was found. nullptr if needle could not be found.Performs printf formatting into a buffer.
| buffer | Pointer to the buffer to receive the formatted string. |
| buffer_size | Size of the buffer. |
| format | printf formatting string. |
| ... | Parameters for the formatting. |
Performs printf formatting into a buffer.
| buffer | Pointer to the buffer to receive the formatted string. |
| buffer_size | Size of the buffer. |
| format | printf formatting string. |
| args | The variable argument list. |
Check whether string has ASCII control characters.
| str | String to check. |
Takes a datablock and generates a hex string of it, with spaces between bytes.
| dst | Buffer to fill with hex data. |
| dst_size | Size of the buffer (at least 3 * data_size + 1 to contain all data). |
| data | Data to turn into hex. |
| data_size | Size of the data. |
| 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.
| dst | Buffer to fill with hex data. |
| dst_size | Size of the buffer (at least 6 * data_size + 1 to contain all data). |
| data | Data to turn into hex. |
| data_size | Size of the data. |
| bytes_per_line | After this many printed bytes a newline will be printed. |
Takes a hex string without spaces between bytes and returns a byte array.
| dst | Buffer for the byte array. |
| dst_size | size of the buffer. |
| data | String to decode. |
2 if string doesn't exactly fit the buffer. 1 if invalid character in string. 0 if success.Determines whether a character is whitespace.
| c | the character to check. |
1 if the character is whitespace, 0 otherwise.Returns the length of a null-terminated string.
| str | Pointer to the string. |
| 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.
| str | Pointer to string. |
| delim | Delimiter for tokenization. |
| buffer | Buffer to store token in. |
| buffer_size | Size of the buffer. |
Finds the last occurrence of a character
| haystack | String to search in. |
| needle | Character to search for. |
nullptr if needle could not be found.Replaces all characters below 32 with whitespace with exception to \t,
and \r.
| str | String to sanitize. |
Replaces all characters below 32 with whitespace.
| str | String to sanitize. |
Skips leading non-whitespace characters.
| str | Pointer to the string. |
Skips leading whitespace characters.
| str | Pointer to the string. |
Checks case sensitive whether the string begins with a certain prefix.
| str | String to check. |
| prefix | Prefix to look for. |
str after the string prefix, or nullptr if the string prefix isn't a prefix of the string str.Checks case insensitive whether the string begins with a certain prefix.
| str | String to check. |
| prefix | Prefix to look for. |
str after the string prefix, or nullptr if the string prefix isn't a prefix of the string str.Copies a timestamp in the format year-month-day_hour-minute-second to the string.
| buffer | Pointer to a buffer that shall receive the timestamp string. |
| buffer_size | Size of the buffer. |
Trims specific number of words at the start of a string.
| str | String to trim the words from. |
| words | Count of words to trim. |
Truncates a string to a given length.
| dst | Pointer to a buffer that shall receive the string. |
| dst_size | Size of the buffer dst. |
| src | String to be truncated. |
| truncation_len | Maximum length of the returned string (not counting the null-termination). |
| 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.
| a | First string for the edit distance. |
| a_len | Length of the first string. |
| b | Second string for the edit distance. |
| b_len | Length of the second string. |
| buf | Buffer for the function. |
| buf_len | Length of the buffer, must be at least as long as the length of both strings combined plus two. |
Checks if a strings contains just valid UTF-8 characters.
| str | Pointer to a possible UTF-8 string. |
0 if invalid characters were found, 1 if only valid characters were found.Checks if two strings only differ by confusable characters.
| str1 | String to compare. |
| str2 | String to compare. |
0 if the strings are confusables. Compares two UTF-8 strings case insensitively.
| a | String to compare. |
| b | String to compare. |
< 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. Compares up to num bytes of two UTF-8 strings case insensitively.
| a | String to compare. |
| b | String to compare. |
| num | Maximum bytes to compare. |
< 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. Copies a number of UTF-8 characters from one string to another.
| dst | Pointer to a buffer that shall receive the string. |
| src | String to be copied. |
| dst_size | Size of the buffer dst. |
| num | Maximum number of UTF-8 characters to be copied. |
Decodes a UTF-8 codepoint.
| ptr | Pointer to a UTF-8 string. This pointer will be moved forward. |
-1 for invalid input and 0 for end of string.Computes the edit distance between two strings, allows buffers to be passed in.
| a | First string for the edit distance. |
| b | Second string for the edit distance. |
| buf | Buffer for the function. |
| buf_len | Length of the buffer, must be at least as long as twice the length of both strings combined plus two. |
Encode a UTF-8 character.
| ptr | Pointer to a buffer that should receive the data. Should be able to hold at least 4 bytes. |
| 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.
| haystack | String to search in. |
| needle | String to search for. |
| end | A 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. |
nullptr if needle could not be found.Fixes truncation of a Unicode character at the end of a UTF-8 string.
| str | UTF-8 string. |
Moves a cursor forwards in an UTF-8 string.
| str | UTF-8 string. |
| cursor | Position in the string. |
Checks whether the given Unicode codepoint renders as space.
| code | Unicode codepoint to check. |
Checks whether a given byte is the start of a UTF-8 character.
| c | Byte to check. |
Converts a byte offset of a UTF-8 string to the UTF-8 character offset.
| text | Pointer to the string. |
| byte_offset | Offset in bytes. |
Converts a UTF-8 character offset of a UTF-8 string to the byte offset.
| text | Pointer to the string. |
| char_offset | Offset in UTF-8 characters. |
Moves a cursor backwards in an UTF-8 string,
| str | UTF-8 string. |
| cursor | Position in the string. |
Skips leading characters that render as spaces.
| str | Input string. |
| 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.
| str | Pointer to the string. |
| max_size | Maximum number of bytes to count. |
| max_count | Maximum number of UTF-8 characters to count. |
| size | Pointer to store size (number of non. Zero bytes) of the string. |
| count | Pointer to store count of UTF-8 characters of the string. |
Converts the given UTF-8 string to lowercase (locale insensitive).
| str | String to convert to lowercase. |
| output | Buffer that will receive the lowercase string. |
| size | Size of the output buffer. |
Converts the given Unicode codepoint to lowercase (locale insensitive).
| code | Unicode codepoint to convert. |
Removes trailing characters that render as spaces by modifying the string in-place.
| param | Input string. |
Truncates a UTF-8 encoded string to a given length.
| dst | Pointer to a buffer that shall receive the string. |
| dst_size | Size of the buffer dst. |
| str | String to be truncated. |
| truncation_len | Maximum codepoints in the returned string. |