Str

struct Str {}

Members

Static functions

asciiDigitValue
int asciiDigitValue(char c)

Determines the numeric value of a character as a decimal digit. Differs from g_unichar_digit_value() because it takes a char, so there's no worry about sign extension if characters are signed.

asciiDtostr
string asciiDtostr(string buffer, int bufLen, double d)

Converts a gdouble to a string, using the '.' as decimal point.

asciiFormatd
string asciiFormatd(string buffer, int bufLen, string format, double d)

Converts a gdouble to a string, using the '.' as decimal point. To format the number you pass in a printf()-style format string. Allowed conversion specifiers are 'e', 'E', 'f', 'F', 'g' and 'G'.

asciiStrcasecmp
int asciiStrcasecmp(string s1, string s2)

Compare two strings, ignoring the case of ASCII characters.

asciiStrdown
string asciiStrdown(string str, ptrdiff_t len)

Converts all upper case ASCII letters to lower case ASCII letters.

asciiStringToSigned
bool asciiStringToSigned(string str, uint base, long min, long max, long outNum)

A convenience function for converting a string to a signed number.

asciiStringToUnsigned
bool asciiStringToUnsigned(string str, uint base, ulong min, ulong max, ulong outNum)

A convenience function for converting a string to an unsigned number.

asciiStrncasecmp
int asciiStrncasecmp(string s1, string s2, size_t n)

Compare s1 and s2, ignoring the case of ASCII characters and any characters after the first n in each string.

asciiStrtod
double asciiStrtod(string nptr, string endptr)

Converts a string to a gdouble value.

asciiStrtoll
long asciiStrtoll(string nptr, string endptr, uint base)

Converts a string to a gint64 value. This function behaves like the standard strtoll() function does in the C locale. It does this without actually changing the current locale, since that would not be thread-safe.

asciiStrtoull
ulong asciiStrtoull(string nptr, string endptr, uint base)

Converts a string to a guint64 value. This function behaves like the standard strtoull() function does in the C locale. It does this without actually changing the current locale, since that would not be thread-safe.

asciiStrup
string asciiStrup(string str, ptrdiff_t len)

Converts all lower case ASCII letters to upper case ASCII letters.

asciiTolower
char asciiTolower(char c)

Convert a character to ASCII lower case.

asciiToupper
char asciiToupper(char c)

Convert a character to ASCII upper case.

asciiXdigitValue
int asciiXdigitValue(char c)

Determines the numeric value of a character as a hexidecimal digit. Differs from g_unichar_xdigit_value() because it takes a char, so there's no worry about sign extension if characters are signed.

freeString
void freeString(char* str)
freeStringArray
void freeStringArray(char** str)
freeStringArray
void freeStringArray(char*** str)
hasPrefix
bool hasPrefix(string str, string prefix)

Looks whether the string str begins with prefix.

hasSuffix
bool hasSuffix(string str, string suffix)

Looks whether the string str ends with suffix.

isAscii
bool isAscii(string str)

Determines if a string is pure ASCII. A string is pure ASCII if it contains no bytes with the high bit set.

matchString
bool matchString(string searchTerm, string potentialHit, bool acceptAlternates)

Checks if a search conducted for search_term should match potential_hit.

printfStringUpperBound
size_t printfStringUpperBound(string format, void* args)

Calculates the maximum space needed to store the output of the sprintf() function.

stpcpy
string stpcpy(string dest, string src)

Copies a nul-terminated string into the dest buffer, include the trailing nul, and return a pointer to the trailing nul byte. This is useful for concatenating multiple strings together without having to repeatedly scan for the end.

strcanon
string strcanon(string string_, string validChars, char substitutor)

For each character in string, if the character is not in valid_chars, replaces the character with substitutor. Modifies string in place, and return string itself, not a copy. The return value is to allow nesting such as

strcasecmp
int strcasecmp(string s1, string s2)

A case-insensitive string comparison, corresponding to the standard strcasecmp() function on platforms which support it.

strchomp
string strchomp(string string_)

Removes trailing whitespace from a string.

strchug
string strchug(string string_)

Removes leading whitespace from a string, by moving the rest of the characters forward.

strcmp0
int strcmp0(string str1, string str2)

Compares str1 and str2 like strcmp(). Handles NULL gracefully by sorting it before non-NULL strings. Comparing two NULL pointers returns 0.

strcompress
string strcompress(string source)

Replaces all escaped characters with their one byte equivalent.

strdelimit
string strdelimit(string string_, string delimiters, char newDelimiter)

Converts any delimiter characters in string to new_delimiter. Any characters in string which are found in delimiters are changed to the new_delimiter character. Modifies string in place, and returns string itself, not a copy. The return value is to allow nesting such as

strdown
string strdown(string string_)

Converts a string to lower case.

strdup
string strdup(string str)

Duplicates a string. If str is NULL it returns NULL. The returned string should be freed with g_free() when no longer needed.

strdupVprintf
string strdupVprintf(string format, void* args)

Similar to the standard C vsprintf() function but safer, since it calculates the maximum space required and allocates memory to hold the result. The returned string should be freed with g_free() when no longer needed.

strdupv
string[] strdupv(string[] strArray)

Copies NULL-terminated array of strings. The copy is a deep copy; the new array should be freed by first freeing each string, then the array itself. g_strfreev() does this for you. If called on a NULL value, g_strdupv() simply returns NULL.

strerror
string strerror(int errnum)

Returns a string corresponding to the given error code, e.g. "no such process". Unlike strerror(), this always returns a string in UTF-8 encoding, and the pointer is guaranteed to remain valid for the lifetime of the process.

strescape
string strescape(string source, string exceptions)

Escapes the special characters '\b', '\f', '\n', '\r', '\t', '\v', '\' and '"' in the string source by inserting a '\' before them. Additionally all characters in the range 0x01-0x1F (everything below SPACE) and in the range 0x7F-0xFF (all non-ASCII chars) are replaced with a '\' followed by their octal representation. Characters supplied in exceptions are not escaped.

strfreev
void strfreev(string[] strArray)

Frees a NULL-terminated array of strings, as well as each string it contains.

strjoinv
string strjoinv(string separator, string[] strArray)

Joins a number of strings together to form one long string, with the optional separator inserted between each of them. The returned string should be freed with g_free().

strlcat
size_t strlcat(string dest, string src, size_t destSize)

Portability wrapper that calls strlcat() on systems which have it, and emulates it otherwise. Appends nul-terminated src string to dest, guaranteeing nul-termination for dest. The total size of dest won't exceed dest_size.

strlcpy
size_t strlcpy(string dest, string src, size_t destSize)

Portability wrapper that calls strlcpy() on systems which have it, and emulates strlcpy() otherwise. Copies src to dest; dest is guaranteed to be nul-terminated; src must be nul-terminated; dest_size is the buffer size, not the number of bytes to copy.

strncasecmp
int strncasecmp(string s1, string s2, uint n)

A case-insensitive string comparison, corresponding to the standard strncasecmp() function on platforms which support it. It is similar to g_strcasecmp() except it only compares the first n characters of the strings.

strndup
string strndup(string str, size_t n)

Duplicates the first n bytes of a string, returning a newly-allocated buffer n + 1 bytes long which will always be nul-terminated. If str is less than n bytes long the buffer is padded with nuls. If str is NULL it returns NULL. The returned value should be freed when no longer needed.

strnfill
string strnfill(size_t length, char fillChar)

Creates a new string length bytes long filled with fill_char. The returned string should be freed when no longer needed.

strreverse
string strreverse(string string_)

Reverses all of the bytes in a string. For example, g_strreverse ("abcdef") will result in "fedcba".

strrstr
string strrstr(string haystack, string needle)

Searches the string haystack for the last occurrence of the string needle.

strrstrLen
string strrstrLen(string haystack, ptrdiff_t haystackLen, string needle)

Searches the string haystack for the last occurrence of the string needle, limiting the length of the search to haystack_len.

strsignal
string strsignal(int signum)

Returns a string describing the given signal, e.g. "Segmentation fault". You should use this function in preference to strsignal(), because it returns a string in UTF-8 encoding, and since not all platforms support the strsignal() function.

strsplit
string[] strsplit(string string_, string delimiter, int maxTokens)

Splits a string into a maximum of max_tokens pieces, using the given delimiter. If max_tokens is reached, the remainder of string is appended to the last token.

strsplitSet
string[] strsplitSet(string string_, string delimiters, int maxTokens)

Splits string into a number of tokens not containing any of the characters in delimiter. A token is the (possibly empty) longest string that does not contain any of the characters in delimiters. If max_tokens is reached, the remainder is appended to the last token.

strstrLen
string strstrLen(string haystack, ptrdiff_t haystackLen, string needle)

Searches the string haystack for the first occurrence of the string needle, limiting the length of the search to haystack_len.

strtod
double strtod(string nptr, string endptr)

Converts a string to a gdouble value. It calls the standard strtod() function to handle the conversion, but if the string is not completely converted it attempts the conversion again with g_ascii_strtod(), and returns the best match.

strup
string strup(string string_)

Converts a string to upper case.

strvContains
bool strvContains(string strv, string str)

Checks if strv contains str. strv must not be NULL.

strvEqual
bool strvEqual(string strv1, string strv2)

Checks if strv1 and strv2 contain exactly the same elements in exactly the same order. Elements are compared using g_str_equal(). To match independently of order, sort the arrays first (using g_qsort_with_data() or similar).

strvGetType
GType strvGetType()
strvLength
uint strvLength(string[] strArray)

Returns the length of the given NULL-terminated string array str_array. str_array must not be NULL.

toAscii
string toAscii(string str, string fromLocale)

Transliterate str to plain ASCII.

toStringArray
string[] toStringArray(const(char*)* args)
toStringArray
string[] toStringArray(const(char*)* args, size_t len)
toStringArray
string[][] toStringArray(char*** args)
toStringzArray
char** toStringzArray(string[] args)
toStringzArray
char*** toStringzArray(string[][] args)
tokenizeAndFold
string[] tokenizeAndFold(string string_, string translitLocale, string[] asciiAlternates)

Tokenises string and performs folding on each token.

vasprintf
int vasprintf(string[] string_, string format, void* args)

An implementation of the GNU vasprintf() function which supports positional parameters, as specified in the Single Unix Specification. This function is similar to g_vsprintf(), except that it allocates a string to hold the output, instead of putting the output in a buffer you allocate in advance.

vfprintf
int vfprintf(FILE* file, string format, void* args)

An implementation of the standard fprintf() function which supports positional parameters, as specified in the Single Unix Specification.

vprintf
int vprintf(string format, void* args)

An implementation of the standard vprintf() function which supports positional parameters, as specified in the Single Unix Specification.

vsnprintf
int vsnprintf(string string_, gulong n, string format, void* args)

A safer form of the standard vsprintf() function. The output is guaranteed to not exceed n characters (including the terminating nul character), so it is easy to ensure that a buffer overflow cannot occur.

vsprintf
int vsprintf(string string_, string format, void* args)

An implementation of the standard vsprintf() function which supports positional parameters, as specified in the Single Unix Specification.