regify utility  2.0.0-0
String Functions

This section contains utilities relating to string manipulation. More...

Modules

 String Object
 A String buffer implementation. This implementation allows for dynamically creating string and appending to them in a reasonably efficient matter.
 

Macros

#define ruUtf8Nfc   1
 Normalizer Mode for NFC normalization for ruUtf8CaseNormalize. More...
 
#define ruUtf8Nfd   2
 Normalizer Mode for NFD normalization for ruUtf8CaseNormalize. More...
 
#define ruUtf8NoCase   0
 Casemode constant to leave case for ruUtf8CaseNormalize intact. More...
 
#define ruUtf8Lower   1
 Casemode constant to lower case text for ruUtf8CaseNormalize. More...
 
#define ruUtf8Upper   2
 Casemode constant to lower case text for ruUtf8CaseNormalize. More...
 

Enumerations

enum  ruTrimSide { ruTrimBoth = (uint32_t)0 , ruTrimStart = 1 , ruTrimEnd = 2 }
 

Functions

RUAPI char * ruUtf8CaseNormalize (const char *instr, int32_t normMode, int32_t caseMode)
 Returns the given string normalized and/or case switched as requested. More...
 
RUAPI alloc_chars ruStrFromNfd (trans_chars instr)
 Returns the given decomposed string in precomposed form. More...
 
RUAPI alloc_chars ruStrToNfd (trans_chars instr)
 Returns the given string in decomposed form. More...
 
RUAPI void ruStrByteReplace (char *string, char search, char replace)
 Replaces any occurrence of search in string with replace. More...
 
RUAPI alloc_chars ruStrReplace (trans_chars instr, trans_chars search, trans_chars replace)
 Replaces any occurrence of search in instr with replace. More...
 
RUAPI int32_t ruStrCmp (trans_chars str1, trans_chars str2)
 Returns what libc strcmp would return but in a manner that gracefully handles NULL imputs. More...
 
RUAPI bool ruStrEquals (trans_chars str1, trans_chars str2)
 Returns true when libc strcmp would return 0 but in a manner that gracefully handles NULL imputs. More...
 
RUAPI bool ruStrNEquals (trans_chars str1, rusize s1len, trans_chars str2)
 Returns true when str2 is equal to the first len number of bytes in str1 or both str1 and str2 are NULL or if len is NULL. More...
 
RUAPI int32_t ruStrCaseCmp (trans_chars str1, trans_chars str2)
 Returns what libc strcasecmp would return but in a manner that gracefully handles NULL imputs. More...
 
RUAPI bool ruStrCaseEquals (trans_chars str1, trans_chars str2)
 Returns true when libc strcasecmp would return 0 but in a manner that gracefully handles NULL imputs. More...
 
RUAPI bool ruStrStartsWith (trans_chars str, trans_chars prefix, int32_t *code)
 Whether given string starts with given prefix. More...
 
RUAPI bool ruStrCaseStartsWith (trans_chars str, trans_chars prefix, int32_t *code)
 Whether given string starts with given prefix ignoring case. More...
 
RUAPI bool ruStrEndsWith (trans_chars str, trans_chars suffix, int32_t *code)
 Whether given string ends with given suffix. More...
 
RUAPI bool ruStrCaseEndsWith (trans_chars str, trans_chars suffix, int32_t *code)
 Whether given string ends with given suffix ignoring case. More...
 
RUAPI trans_chars ruStrCaseStrLen (trans_chars haystack, trans_chars needle, rusize len)
 Searches the first instance of lowercase needle in lowercase haystack up to len bytes. Lowercasing is only ASCII compatible. More...
 
RUAPI trans_chars ruStrStrLen (trans_chars haystack, trans_chars needle, rusize len)
 Searches the first instance of needle in haystack up to len bytes. More...
 
RUAPI trans_chars ruStrStr (trans_chars haystack, trans_chars needle)
 Searches the first instance of needle in haystack. More...
 
RUAPI trans_chars ruLastSubStrLen (trans_chars haystack, trans_chars needle, rusize len)
 Searches the last instance of needle in haystack up to len bytes. More...
 
RUAPI trans_chars ruLastSubStr (trans_chars haystack, trans_chars needle)
 Searches the last instance of needle in haystack. More...
 
RUAPI ruList ruStrNSplit (trans_chars instr, rusize inlen, trans_chars delim, int32_t maxCnt)
 Split given instr up to inlen bytes with delim into a ruList. More...
 
RUAPI ruList ruStrSplit (trans_chars instr, trans_chars delim, int32_t maxCnt)
 split given instr with delim into a ruList. More...
 
RUAPI char ruAsciiCharToLower (char in)
 Returns lowercase representation of given ASCII character. More...
 
RUAPI alloc_chars ruAsciiToLower (trans_chars instr)
 Returns a lowercase copy of given ASCII string. More...
 
RUAPI alloc_chars ruAsciiNToLower (trans_chars instr, rusize len)
 Returns a lowercase copy of len bytes of given ASCII string. More...
 
RUAPI char ruAsciiCharToUpper (char in)
 Returns uppercase representation of given ASCII character. More...
 
RUAPI alloc_chars ruAsciiToUpper (trans_chars instr)
 Returns a uppercase copy of given ASCII string. More...
 
RUAPI alloc_chars ruAsciiNToUpper (trans_chars instr, rusize len)
 Returns a uppercase copy of len bytes of given ASCII string. More...
 
RUAPI alloc_chars ruUtf8ToLower (trans_chars instr)
 Returns a lowercase copy of given UTF8 string. More...
 
RUAPI alloc_chars ruUtf8ToUpper (trans_chars instr)
 Returns a uppercase copy of given UTF8 string. More...
 
RUAPI alloc_chars ruStrFromNUtf16 (trans_uni unistr, int32_t bytelen)
 Converts given UTF16 wide character sequence to UTF8. More...
 
RUAPI alloc_chars ruStrFromUtf16 (trans_uni unistr)
 Converts given UTF16 wide character sequence to UTF8. More...
 
RUAPI alloc_uni ruStrNToUtf16 (trans_chars str, int32_t bytelen)
 Converts given UTF8 string to UTF16 as it is used on Windows. More...
 
RUAPI alloc_uni ruStrToUtf16 (trans_chars str)
 Converts given UTF8 string to UTF16 as it is used on Windows. More...
 
RUAPI char * ruStrDup (const char *str)
 Returns a copy of given string. More...
 
RUAPI rusize ruStrLen (trans_chars str)
 behaves like strlen but returns 0 if NULL is passed in More...
 
RUAPI char * ruStrNDup (const char *str, rusize len)
 Returns a copy of len bytes of given string. More...
 
RUAPI char * ruDupvPrintf (const char *format, va_list arglist)
 Returns an allocated string from given vprintf call. More...
 
RUAPI char * ruDupPrintf (const char *format,...)
 Returns an allocated string from given printf call. More...
 
RUAPI int32_t ruStrParseInt64 (trans_chars str, perm_chars *endptr, uint32_t base, int64_t *num)
 
RUAPI int64_t ruStrToInt64 (trans_chars str)
 Like ruStrParseInt64 but ignores overflow and trailing garbage. More...
 
RUAPI int32_t ruStrParseLong (trans_chars str, perm_chars *endptr, uint32_t base, long *num)
 
RUAPI long ruStrToLong (trans_chars str)
 Like ruStrParseLong but ignores overflow and trailing garbage. More...
 
RUAPI int32_t ruStrParseInt (trans_chars str, perm_chars *endptr, uint32_t base, int32_t *num)
 
RUAPI int32_t ruStrToInt (trans_chars str)
 Like ruStrParseInt but ignores overflow and trailing garbage. More...
 
RUAPI bool ruStrHasChar (trans_chars haystack, char needle)
 
RUAPI perm_chars ruStrStrip (perm_chars instr, trans_chars unwanted, alloc_chars *newstr)
 Removes unwanted characters from instr. More...
 
RUAPI perm_chars ruStrTrim (perm_chars instr, trans_chars unwanted, enum ruTrimSide ends, alloc_chars *newstr)
 Checks given string for leading / trailing unwanted characters and returns trimmed copy if needed. More...
 
RUAPI trans_chars ruStrTrimBounds (trans_chars inStart, rusize inLen, rusize *outLen)
 Returns the white space trimmed bounds of given string without modifying it. More...
 
RUAPI bool ruStrFindKeyVal (trans_chars inStart, rusize inLen, trans_chars delim, trans_chars *keyStart, rusize *keyLen, trans_chars *valStart, rusize *valLen)
 Parses whitespace trimmed key / value regions based on delim out of given input string. More...
 
RUAPI bool ruStrEmpty (trans_chars str)
 Checks whether given string has any content other than whitespace. More...
 

Detailed Description

This section contains utilities relating to string manipulation.

Macro Definition Documentation

◆ ruUtf8Lower

#define ruUtf8Lower   1

Casemode constant to lower case text for ruUtf8CaseNormalize.

◆ ruUtf8Nfc

#define ruUtf8Nfc   1

Normalizer Mode for NFC normalization for ruUtf8CaseNormalize.

◆ ruUtf8Nfd

#define ruUtf8Nfd   2

Normalizer Mode for NFD normalization for ruUtf8CaseNormalize.

◆ ruUtf8NoCase

#define ruUtf8NoCase   0

Casemode constant to leave case for ruUtf8CaseNormalize intact.

◆ ruUtf8Upper

#define ruUtf8Upper   2

Casemode constant to lower case text for ruUtf8CaseNormalize.

Enumeration Type Documentation

◆ ruTrimSide

enum ruTrimSide

Constants used by ruStrTrim to indicate the trimming sides.

Enumerator
ruTrimBoth 

Trim character off the beginning and the end of the given string.

ruTrimStart 

Trim character off the beginning of the given string.

ruTrimEnd 

Trim character off the end of the given string.

Function Documentation

◆ ruAsciiCharToLower()

RUAPI char ruAsciiCharToLower ( char  in)

Returns lowercase representation of given ASCII character.

Parameters
inCharacter to lowercase.
Returns
The lowercase version of given character or the same if not uppercase ASCII.

◆ ruAsciiCharToUpper()

RUAPI char ruAsciiCharToUpper ( char  in)

Returns uppercase representation of given ASCII character.

Parameters
inCharacter to lowercase.
Returns
The uppercase version of given character or the same if not lowercase ASCII.

◆ ruAsciiNToLower()

RUAPI alloc_chars ruAsciiNToLower ( trans_chars  instr,
rusize  len 
)

Returns a lowercase copy of len bytes of given ASCII string.

Parameters
instrString to lowercase.
lenThe number of bytes to consider
Returns
Lowercase representation of given string. Free with ruFree.

◆ ruAsciiNToUpper()

RUAPI alloc_chars ruAsciiNToUpper ( trans_chars  instr,
rusize  len 
)

Returns a uppercase copy of len bytes of given ASCII string.

Parameters
instrString to uppercase.
lenThe number of bytes to consider
Returns
Uppercase representation of given string. Free with ruFree.

◆ ruAsciiToLower()

RUAPI alloc_chars ruAsciiToLower ( trans_chars  instr)

Returns a lowercase copy of given ASCII string.

Parameters
instrString to lowercase.
Returns
Lowercase representation of given string. Free with ruFree.

◆ ruAsciiToUpper()

RUAPI alloc_chars ruAsciiToUpper ( trans_chars  instr)

Returns a uppercase copy of given ASCII string.

Parameters
instrString to uppercase.
Returns
Uppercase representation of given string. Free with ruFree.

◆ ruDupPrintf()

RUAPI char* ruDupPrintf ( const char *  format,
  ... 
)

Returns an allocated string from given printf call.

Parameters
formatPrintf style format string
...Remaining arguments for the format string.
Returns
Allocated string copy of formatted string. Free with ruFree.

◆ ruDupvPrintf()

RUAPI char* ruDupvPrintf ( const char *  format,
va_list  arglist 
)

Returns an allocated string from given vprintf call.

Parameters
formatPrintf style format string
arglista va_start initialized argument list
Returns
Allocated string copy of formatted string. Free with ruFree.

◆ ruLastSubStr()

RUAPI trans_chars ruLastSubStr ( trans_chars  haystack,
trans_chars  needle 
)

Searches the last instance of needle in haystack.

Parameters
haystackString to search needle in.
needleString to find in haystack.
Returns
Start of the last found instance of haystack or NULL if not found.

◆ ruLastSubStrLen()

RUAPI trans_chars ruLastSubStrLen ( trans_chars  haystack,
trans_chars  needle,
rusize  len 
)

Searches the last instance of needle in haystack up to len bytes.

Parameters
haystackString to search needle in.
needleString to find in haystack.
lenMaximum number of bytes in haystack to consider.
Returns
Start of the last found instance of haystack or NULL if not found.

◆ ruStrByteReplace()

RUAPI void ruStrByteReplace ( char *  string,
char  search,
char  replace 
)

Replaces any occurrence of search in string with replace.

This function works byte level not character level. NOTE: Calling this function with strings on the stack will segfault.

Parameters
stringString to process
searchCharacter to replace
replaceCharacter to replace search with

◆ ruStrCaseCmp()

RUAPI int32_t ruStrCaseCmp ( trans_chars  str1,
trans_chars  str2 
)

Returns what libc strcasecmp would return but in a manner that gracefully handles NULL imputs.

Parameters
str1The first string to check.
str2The second string to compare to the first.
Returns
-1, 1 or 0 in case of them being equal or both NULL.

◆ ruStrCaseEndsWith()

RUAPI bool ruStrCaseEndsWith ( trans_chars  str,
trans_chars  suffix,
int32_t *  code 
)

Whether given string ends with given suffix ignoring case.

Parameters
strString to check.
suffixSuffix to test for.
code(Optional) Stores RUE_OK on success or regify error code.
Returns
Whether string ends with the suffix.

◆ ruStrCaseEquals()

RUAPI bool ruStrCaseEquals ( trans_chars  str1,
trans_chars  str2 
)

Returns true when libc strcasecmp would return 0 but in a manner that gracefully handles NULL imputs.

Parameters
str1The first string to check.
str2The second string to compare to the first.
Returns
true if both strings are the same or NULL

◆ ruStrCaseStartsWith()

RUAPI bool ruStrCaseStartsWith ( trans_chars  str,
trans_chars  prefix,
int32_t *  code 
)

Whether given string starts with given prefix ignoring case.

Parameters
strString to check.
prefixPrefix to test for.
code(Optional) Stores RUE_OK on success or regify error code.
Returns
Whether string starts with the prefix.

◆ ruStrCaseStrLen()

RUAPI trans_chars ruStrCaseStrLen ( trans_chars  haystack,
trans_chars  needle,
rusize  len 
)

Searches the first instance of lowercase needle in lowercase haystack up to len bytes. Lowercasing is only ASCII compatible.

Parameters
haystackString to search needle in.
needleString to find in haystack.
lenMaximum number of bytes in haystack to consider.
Returns
Start of the first found instance of haystack or NULL if not found.

◆ ruStrCmp()

RUAPI int32_t ruStrCmp ( trans_chars  str1,
trans_chars  str2 
)

Returns what libc strcmp would return but in a manner that gracefully handles NULL imputs.

Parameters
str1The first string to check.
str2The second string to compare to the first.
Returns
-1, 1 or 0 in case of them being equal or both NULL.

◆ ruStrDup()

RUAPI char* ruStrDup ( const char *  str)

Returns a copy of given string.

Parameters
strString to copy
Returns
Copy of given string or NULL if NULL was given. Free with ruFree.

◆ ruStrEmpty()

RUAPI bool ruStrEmpty ( trans_chars  str)

Checks whether given string has any content other than whitespace.

Parameters
strString to inspect
Returns
true if NULL empty or only white space

◆ ruStrEndsWith()

RUAPI bool ruStrEndsWith ( trans_chars  str,
trans_chars  suffix,
int32_t *  code 
)

Whether given string ends with given suffix.

Parameters
strString to check.
suffixSuffix to test for.
code(Optional) Stores RUE_OK on success or regify error code.
Returns
Whether string ends with the suffix.

◆ ruStrEquals()

RUAPI bool ruStrEquals ( trans_chars  str1,
trans_chars  str2 
)

Returns true when libc strcmp would return 0 but in a manner that gracefully handles NULL imputs.

Parameters
str1The first string to check.
str2The second string to compare to the first.
Returns
true if both strings are the same or NULL

◆ ruStrFindKeyVal()

RUAPI bool ruStrFindKeyVal ( trans_chars  inStart,
rusize  inLen,
trans_chars  delim,
trans_chars keyStart,
rusize keyLen,
trans_chars valStart,
rusize valLen 
)

Parses whitespace trimmed key / value regions based on delim out of given input string.

Parameters
inStartStart of the string to parse
inLenNumber of bytes to evaluate or RU_SIZE_AUTO.
delimDelimiter sequence to split key / value on
keyStartOptional, where the start of the key region will be stored
keyLenOptional, where the length of the key region will be stored
valStartOptional, where the start of the value region will be stored
valLenOptional, where the length of the value region will be stored
Returns
true if delimiter was found. When false only the key parameters will be set.

◆ ruStrFromNfd()

RUAPI alloc_chars ruStrFromNfd ( trans_chars  instr)

Returns the given decomposed string in precomposed form.

See also
https://en.wikipedia.org/wiki/Unicode_equivalence#Normal_forms
Parameters
instrDecomposed UTF8 string.
Returns
Standard precomposed UTF8 string.

◆ ruStrFromNUtf16()

RUAPI alloc_chars ruStrFromNUtf16 ( trans_uni  unistr,
int32_t  bytelen 
)

Converts given UTF16 wide character sequence to UTF8.

Parameters
unistrUTF16 string to convert.
bytelenLength of unistr without terminating bytes or -1 to detect length
Returns
UTF8 representation of unistr. Caller must free.

◆ ruStrFromUtf16()

RUAPI alloc_chars ruStrFromUtf16 ( trans_uni  unistr)

Converts given UTF16 wide character sequence to UTF8.

Parameters
unistrUTF16 string to convert.
Returns
UTF8 representation of unistr. Caller must free.

◆ ruStrHasChar()

RUAPI bool ruStrHasChar ( trans_chars  haystack,
char  needle 
)

Returns true if given haystack contains needle character

Parameters
haystackstring to search for needle
needlecharacter to search in haystack
Returns
whether it is found

◆ ruStrLen()

RUAPI rusize ruStrLen ( trans_chars  str)

behaves like strlen but returns 0 if NULL is passed in

Parameters
strstring to get length of
Returns
length of given string or 0 if string was NULL.

◆ ruStrNDup()

RUAPI char* ruStrNDup ( const char *  str,
rusize  len 
)

Returns a copy of len bytes of given string.

Parameters
strString to copy
lenNumber of bytes to consider.
Returns
Copy of given string or NULL if NULL was given. Free with ruFree.

◆ ruStrNEquals()

RUAPI bool ruStrNEquals ( trans_chars  str1,
rusize  s1len,
trans_chars  str2 
)

Returns true when str2 is equal to the first len number of bytes in str1 or both str1 and str2 are NULL or if len is NULL.

Parameters
str1The first string to check.
s1lenNumber of bytes in str1 to consider
str2The second string to compare to the first.
Returns
true if both strings are the same or NULL

◆ ruStrNSplit()

RUAPI ruList ruStrNSplit ( trans_chars  instr,
rusize  inlen,
trans_chars  delim,
int32_t  maxCnt 
)

Split given instr up to inlen bytes with delim into a ruList.

Parameters
instrString to split.
inlenOptional length delimiter. Use RU_SIZE_AUTO to omit.
delimDelimiter to split string on.
maxCntMaximum number of pieces to return or 0 for no limit. The remainder will be unsplit in the last piece.
Returns
The list of pieces to be free by caller with ruListFree or NULL in case of a parameter error.

◆ ruStrNToUtf16()

RUAPI alloc_uni ruStrNToUtf16 ( trans_chars  str,
int32_t  bytelen 
)

Converts given UTF8 string to UTF16 as it is used on Windows.

Parameters
strUTF8 string to convert
bytelenLength of str without terminating byte or -1 to detect length.
Returns
UTF16 wide character string. Caller must free.

◆ ruStrParseInt()

RUAPI int32_t ruStrParseInt ( trans_chars  str,
perm_chars endptr,
uint32_t  base,
int32_t *  num 
)

Parses the number out of the given string in given base assuming and ignoring comma thousand separators. The decimal point is a period.

Parameters
strString to parse. Leading white space will be skipped.
endptr(Optional) Points to the first character that did not parse properly
basea number between 2 and 36 or 0 for detecting hex with prefix 0x, octal with prefix 0 and else assuming decimal.
numWhere the number result will be stored or 0 on error.
Returns
RUE_OK on success RUE_OVERFLOW when the number did not fit the type or RUE_PARAMETER_NOT_SET and RUE_INVALID_PARAMETER for not given or invalid input.

◆ ruStrParseInt64()

RUAPI int32_t ruStrParseInt64 ( trans_chars  str,
perm_chars endptr,
uint32_t  base,
int64_t *  num 
)

Parses the number out of the given string in given base assuming and ignoring comma thousand separators. The decimal point is a period.

Parameters
strString to parse. Leading white space will be skipped.
endptr(Optional) Points to the first character that did not parse properly
basea number between 2 and 36 or 0 for detecting hex with prefix 0x, octal with prefix 0 and else assuming decimal.
numWhere the number result will be stored or 0 on error.
Returns
RUE_OK on success RUE_OVERFLOW when the number did not fit the type or RUE_PARAMETER_NOT_SET and RUE_INVALID_PARAMETER for not given or invalid input.

◆ ruStrParseLong()

RUAPI int32_t ruStrParseLong ( trans_chars  str,
perm_chars endptr,
uint32_t  base,
long *  num 
)

Parses the number out of the given string in given base assuming and ignoring comma thousand separators. The decimal point is a period.

Parameters
strString to parse. Leading white space will be skipped.
endptr(Optional) Points to the first character that did not parse properly
basea number between 2 and 36 or 0 for detecting hex with prefix 0x, octal with prefix 0 and else assuming decimal.
numWhere the number result will be stored or 0 on error.
Returns
RUE_OK on success RUE_OVERFLOW when the number did not fit the type or RUE_PARAMETER_NOT_SET and RUE_INVALID_PARAMETER for not given or invalid input.

◆ ruStrReplace()

RUAPI alloc_chars ruStrReplace ( trans_chars  instr,
trans_chars  search,
trans_chars  replace 
)

Replaces any occurrence of search in instr with replace.

Parameters
instrString to process
searchString to replace
replaceString to replace search with
Returns
A new string with the replacements made, caller must free.

◆ ruStrSplit()

RUAPI ruList ruStrSplit ( trans_chars  instr,
trans_chars  delim,
int32_t  maxCnt 
)

split given instr with delim into a ruList.

Parameters
instrString to split.
delimDelimiter to split string on.
maxCntMaximum number of pieces to return or 0 for no limit. The remainder will be unsplit in the last piece.
Returns
The list of pieces to be free by caller with ruListFree or NULL in case of a parameter error.

◆ ruStrStartsWith()

RUAPI bool ruStrStartsWith ( trans_chars  str,
trans_chars  prefix,
int32_t *  code 
)

Whether given string starts with given prefix.

Parameters
strString to check.
prefixPrefix to test for.
code(Optional) Stores RUE_OK on success or regify error code.
Returns
Whether string starts with the prefix.

◆ ruStrStr()

RUAPI trans_chars ruStrStr ( trans_chars  haystack,
trans_chars  needle 
)

Searches the first instance of needle in haystack.

Parameters
haystackString to search needle in.
needleString to find in haystack.
Returns
Start of the first found instance of haystack or NULL if not found.

◆ ruStrStrip()

RUAPI perm_chars ruStrStrip ( perm_chars  instr,
trans_chars  unwanted,
alloc_chars newstr 
)

Removes unwanted characters from instr.

Parameters
instrInput string to remove unwanted characters from.
unwantedCharacters to remove or NULL for white space.
newstrWhere a potential new copy of the given string will be stored. Caller must free.
Returns
instr if unmodified or *newstr if unwanted characters where found.

◆ ruStrStrLen()

RUAPI trans_chars ruStrStrLen ( trans_chars  haystack,
trans_chars  needle,
rusize  len 
)

Searches the first instance of needle in haystack up to len bytes.

Parameters
haystackString to search needle in.
needleString to find in haystack.
lenMaximum number of bytes in haystack to consider.
Returns
Start of the first found instance of haystack or NULL if not found.

◆ ruStrToInt()

RUAPI int32_t ruStrToInt ( trans_chars  str)

Like ruStrParseInt but ignores overflow and trailing garbage.

Parameters
strString to contain numerals to parse
Returns
the number

◆ ruStrToInt64()

RUAPI int64_t ruStrToInt64 ( trans_chars  str)

Like ruStrParseInt64 but ignores overflow and trailing garbage.

Parameters
strString to contain numerals to parse
Returns
whatever strtoll returns

◆ ruStrToLong()

RUAPI long ruStrToLong ( trans_chars  str)

Like ruStrParseLong but ignores overflow and trailing garbage.

Parameters
strString to contain numerals to parse
Returns
the number

◆ ruStrToNfd()

RUAPI alloc_chars ruStrToNfd ( trans_chars  instr)

Returns the given string in decomposed form.

See also
https://en.wikipedia.org/wiki/Unicode_equivalence#Normal_forms
Parameters
instrStandard precomposed UTF8 string
Returns
Decomposed UTF8 string.

◆ ruStrToUtf16()

RUAPI alloc_uni ruStrToUtf16 ( trans_chars  str)

Converts given UTF8 string to UTF16 as it is used on Windows.

Parameters
strUTF8 string to convert
Returns
UTF16 wide character string. Caller must free.

◆ ruStrTrim()

RUAPI perm_chars ruStrTrim ( perm_chars  instr,
trans_chars  unwanted,
enum ruTrimSide  ends,
alloc_chars newstr 
)

Checks given string for leading / trailing unwanted characters and returns trimmed copy if needed.

Parameters
instrString to check for trimming
unwantedString containing all unwanted character bytes or NULL to trim whitespace.
endsIndicates which sides to trim
newstrOptional. Where the new string will be stored if it was created. If no trimming took place this will be NULL. This string should be freed by the caller.
Returns
instr if instr was NULL or did not need trimming, instr + trimmed start character if only the beginning needed trimming else the trimmed new string also set in newstr. newstr is to be freed by the caller.

Example:

alloc_chars newstr = NULL;
perm_chars trimstr = ruStrTrim(mystring, NULL, ruTrimBoth, &newstr);
// do whatever with trimstr
ruFree(newstr);
#define ruFree(p)
Frees given resource and sets paramater to NULL.
Definition: regify-util.h:662
const char * perm_chars
A permanent NULL terminated string pointer.
Definition: regify-util.h:176
char * alloc_chars
An allocated NULL terminated string pointer.
Definition: regify-util.h:199
RUAPI perm_chars ruStrTrim(perm_chars instr, trans_chars unwanted, enum ruTrimSide ends, alloc_chars *newstr)
Checks given string for leading / trailing unwanted characters and returns trimmed copy if needed.
@ ruTrimBoth
Definition: string.h:600

◆ ruStrTrimBounds()

RUAPI trans_chars ruStrTrimBounds ( trans_chars  inStart,
rusize  inLen,
rusize outLen 
)

Returns the white space trimmed bounds of given string without modifying it.

Parameters
inStartStart address of string to examine
inLenNumber of bytes to examine or RU_SIZE_AUTO
outLenOptional, where the length of the returned start address will be stored.
Returns
Start address of first non whitespace character or NULL

◆ ruUtf8CaseNormalize()

RUAPI char* ruUtf8CaseNormalize ( const char *  instr,
int32_t  normMode,
int32_t  caseMode 
)

Returns the given string normalized and/or case switched as requested.

Parameters
instrThe string to convert.
normModeNormalization mode of ruUtf8Nfc, ruUtf8Nfd or 0 for untouched.
caseModeCase toggling mode of ruUtf8Lower, ruUtf8Upper or ruUtf8NoCase for untouched.
Returns
A copy of the given string with the requested tranformations made or NULL incase of error. In that case call ruLastError for details.

◆ ruUtf8ToLower()

RUAPI alloc_chars ruUtf8ToLower ( trans_chars  instr)

Returns a lowercase copy of given UTF8 string.

Parameters
instrString to lowercase.
Returns
Lowercase representation of given string. Free with ruFree.

◆ ruUtf8ToUpper()

RUAPI alloc_chars ruUtf8ToUpper ( trans_chars  instr)

Returns a uppercase copy of given UTF8 string.

Parameters
instrString to uppercase.
Returns
Uppercase representation of given string. Free with ruFree.