string.h revision e55bac169c32099901eec0d057b846775f029fba
* @returns iprt status code. * @param ppszString Receives pointer of the allocated UTF-8 string. * The returned pointer must be freed using RTStrFree(). * @param pszString UTF-8 string to duplicate. * Validates the UTF-8 encoding of the string. * @returns iprt status code. /** @name Flags for RTStrValidateEncodingEx /** Check that the string is zero terminated within the given size. * VERR_BUFFER_OVERFLOW will be returned if the check fails. */ * Validates the UTF-8 encoding of the string. * @returns iprt status code. * @param cch The max string length. Use RTSTR_MAX to process the entire string. * @param fFlags Reserved for future. Pass 0. * Checks if the UTF-8 encoding is valid. * Gets the number of code points the string is made up of, excluding * @returns Number of code points (RTUNICP). * @returns 0 if the string was incorrectly encoded. * Gets the number of code points the string is made up of, excluding * This function will validate the string, and incorrectly encoded UTF-8 * strings will be rejected. * @returns iprt status code. * @param cch The max string length. Use RTSTR_MAX to process the entire string. * @param pcuc Where to store the code point count. * This is undefined on failure. * Translate a UTF-8 string into an unicode string (i.e. RTUNICPs), allocating the string buffer. * @returns iprt status code. * @param pszString UTF-8 string to convert. * @param ppUniString Receives pointer to the allocated unicode string. * The returned string must be freed using RTUniFree(). * Translates pszString from UTF-8 to an array of code points, allocating the result * @returns iprt status code. * @param pszString UTF-8 string to convert. * @param cchString The maximum size in chars (the type) to convert. The conversion stop * when it reaches cchString or the string terminator ('\\0'). * Use RTSTR_MAX to translate the entire string. * @param ppaCps If cCps is non-zero, this must either be pointing to pointer to * a buffer of the specified size, or pointer to a NULL pointer. * If *ppusz is NULL or cCps is zero a buffer of at least cCps items * will be allocated to hold the translated string. * If a buffer was requested it must be freed using RTUtf16Free(). * @param cCps The number of code points in the unicode string. This includes the terminator. * @param pcCps Where to store the length of the translated string. (Optional) * This field will be updated even on failure, however the value is only * specified for the following two error codes. On VERR_BUFFER_OVERFLOW * and VERR_NO_STR_MEMORY it contains the required buffer space. * Calculates the length of the string in RTUTF16 items. * This function will validate the string, and incorrectly encoded UTF-8 * strings will be rejected. The primary purpose of this function is to * help allocate buffers for RTStrToUtf16Ex of the correct size. For most * other purposes RTStrCalcUtf16LenEx() should be used. * @returns Number of RTUTF16 items. * @returns 0 if the string was incorrectly encoded. * Calculates the length of the string in RTUTF16 items. * This function will validate the string, and incorrectly encoded UTF-8 * strings will be rejected. * @returns iprt status code. * @param cch The max string length. Use RTSTR_MAX to process the entire string. * @param pcwc Where to store the string length. Optional. * This is undefined on failure. * Translate a UTF-8 string into a UTF-16 allocating the result buffer. * @returns iprt status code. * @param pszString UTF-8 string to convert. * @param ppwszString Receives pointer to the allocated UTF-16 string. * The returned string must be freed using RTUtf16Free(). * Translates pszString from UTF-8 to UTF-16, allocating the result buffer if requested. * @returns iprt status code. * @param pszString UTF-8 string to convert. * @param cchString The maximum size in chars (the type) to convert. The conversion stop * when it reaches cchString or the string terminator ('\\0'). * Use RTSTR_MAX to translate the entire string. * @param ppwsz If cwc is non-zero, this must either be pointing to pointer to * a buffer of the specified size, or pointer to a NULL pointer. * If *ppwsz is NULL or cwc is zero a buffer of at least cwc items * will be allocated to hold the translated string. * If a buffer was requested it must be freed using RTUtf16Free(). * @param cwc The buffer size in RTUTF16s. This includes the terminator. * @param pcwc Where to store the length of the translated string. (Optional) * This field will be updated even on failure, however the value is only * specified for the following two error codes. On VERR_BUFFER_OVERFLOW * and VERR_NO_STR_MEMORY it contains the required buffer space. * Get the unicode code point at the given string position. * @returns unicode code point. * @returns RTUNICP_INVALID if the encoding is invalid. * Get the unicode code point at the given string position. * @returns iprt status code * @returns VERR_INVALID_UTF8_ENCODING if the encoding is invalid. * @param ppsz The string. * @param pCp Where to store the unicode code point. * Stores RTUNICP_INVALID if the encoding is invalid. * Get the unicode code point at the given string position for a string of a * @returns iprt status code * @retval VERR_INVALID_UTF8_ENCODING if the encoding is invalid. * @retval VERR_END_OF_STRING if *pcch is 0. *pCp is set to RTUNICP_INVALID. * @param ppsz The string. * @param pcch Pointer to the length of the string. This will be * decremented by the size of the code point. * @param pCp Where to store the unicode code point. * Stores RTUNICP_INVALID if the encoding is invalid. * Put the unicode code point at the given string position * and return the pointer to the char following it. * This function will not consider anything at or following the * buffer area pointed to by psz. It is therefore not suitable for * @returns pointer to the char following the written code point. * @param CodePoint The code point to write. * This should not be RTUNICP_INVALID or any other * character out of the UTF-8 range. * @remark This is a worker function for RTStrPutCp(). * Get the unicode code point at the given string position. * @returns unicode code point. * @returns RTUNICP_INVALID if the encoding is invalid. * @remark We optimize this operation by using an inline function for * the most frequent and simplest sequence, the rest is * handled by RTStrGetCpInternal(). const unsigned char uch = *(
const unsigned char *)
psz;
* Get the unicode code point at the given string position. * @returns iprt status code. * @param ppsz Pointer to the string pointer. This will be updated to * point to the char following the current code point. * @param pCp Where to store the code point. * RTUNICP_INVALID is stored here on failure. * @remark We optimize this operation by using an inline function for * the most frequent and simplest sequence, the rest is * handled by RTStrGetCpExInternal(). const unsigned char uch = **(
const unsigned char **)
ppsz;
* Get the unicode code point at the given string position for a string of a * @returns iprt status code. * @retval VERR_INVALID_UTF8_ENCODING if the encoding is invalid. * @retval VERR_END_OF_STRING if *pcch is 0. *pCp is set to RTUNICP_INVALID. * @param ppsz Pointer to the string pointer. This will be updated to * point to the char following the current code point. * @param pcch Pointer to the maximum string length. This will be * decremented by the size of the code point found. * @param pCp Where to store the code point. * RTUNICP_INVALID is stored here on failure. * @remark We optimize this operation by using an inline function for * the most frequent and simplest sequence, the rest is * handled by RTStrGetCpNExInternal(). const unsigned char uch = **(
const unsigned char **)
ppsz;
* Put the unicode code point at the given string position * and return the pointer to the char following it. * This function will not consider anything at or following the * buffer area pointed to by psz. It is therefore not suitable for * @returns pointer to the char following the written code point. * @param CodePoint The code point to write. * This should not be RTUNICP_INVALID or any other * character out of the UTF-8 range. * @remark We optimize this operation by using an inline function for * the most frequent and simplest sequence, the rest is * handled by RTStrPutCpInternal(). * Skips ahead, past the current code point. * @returns Pointer to the char after the current code point. * @param psz Pointer to the current code point. * @remark This will not move the next valid code point, only past the current one. * Skips back to the previous code point. * @returns Pointer to the char before the current code point. * @returns pszStart on failure. * @param pszStart Pointer to the start of the string. * @param psz Pointer to the current code point. * @returns number of bytes written. * @param pvArg User argument. * @param pachChars Pointer to an array of utf-8 characters. * @param cbChars Number of bytes in the character array pointed to by pachChars. /** Pointer to callback function. */ * These are used by RTStrFormat extensions and RTStrFormatNumber, mind * that not all flags makes sense to both of the functions. /** @def RTSTR_GET_BIT_FLAG * Gets the bit flag for the specified type. * Callback to format non-standard format specifiers. * @returns The number of bytes formatted. * @param pvArg Formatter argument. * @param pfnOutput Pointer to output function. * @param pvArgOutput Argument for the output function. * @param ppszFormat Pointer to the format string pointer. Advance this till the char * after the format specifier. * @param pArgs Pointer to the argument list. Use this to fetch the arguments. * @param cchWidth Format Width. -1 if not specified. * @param cchPrecision Format Precision. -1 if not specified. * @param fFlags Flags (RTSTR_NTFS_*). * @param chArgSize The argument size specifier, 'l' or 'L'. /** Pointer to a FNSTRFORMAT() function. */ * Partial implementation of a printf like formatter. * It doesn't do everything correct, and there is no floating point support. * However, it supports custom formats by the means of a format callback. * @returns number of bytes formatted. * @param pfnOutput Output worker. * Called in two ways. Normally with a string and its length. * For termination, it's called with NULL for string, 0 for length. * @param pvArgOutput Argument to the output worker. * @param pfnFormat Custom format worker. * @param pvArgFormat Argument to the format worker. * @param pszFormat Format string pointer. * @param InArgs Argument list. * Partial implementation of a printf like formatter. * It doesn't do everything correct, and there is no floating point support. * However, it supports custom formats by the means of a format callback. * @returns number of bytes formatted. * @param pfnOutput Output worker. * Called in two ways. Normally with a string and its length. * For termination, it's called with NULL for string, 0 for length. * @param pvArgOutput Argument to the output worker. * @param pfnFormat Custom format worker. * @param pvArgFormat Argument to the format worker. * @param pszFormat Format string. * @param ... Argument list. * Formats an integer number according to the parameters. * @returns Length of the formatted number. * @param psz Pointer to output string buffer of sufficient size. * @param u64Value Value to format. * @param uiBase Number representation base. * @param cchPrecision Precision. * @param fFlags Flags (NTFS_*). * Callback for formatting a type. * This is registered using the RTStrFormatTypeRegister function and will * be called during string formatting to handle the specified %R[type]. * The argument for this format type is assumed to be a pointer and it's * passed in the @a pvValue argument. * @returns Length of the formatted output. * @param pfnOutput Output worker. * @param pvArgOutput Argument to the output worker. * @param pszType The type name. * @param pvValue The argument value. * @param cchPrecision Precision. * @param fFlags Flags (NTFS_*). * @param pvUser The user argument. /** Pointer to a FNRTSTRFORMATTYPE. */ * Register a format handler for a type. * The format handler is used to handle '%R[type]' format types, where the argument * in the vector is a pointer value (a bit restrictive, but keeps it simple). * The caller must ensure that no other thread will be making use of any of * the dynamic formatting type facilities simultaneously with this call. * @returns IPRT status code. * @retval VINF_SUCCESS on success. * @retval VERR_ALREADY_EXISTS if the type has already been registered. * @retval VERR_TOO_MANY_OPEN_FILES if all the type slots has been allocated already. * @param pszType The type name. * @param pfnHandler The handler address. See FNRTSTRFORMATTYPE for details. * @param pvUser The user argument to pass to the handler. See RTStrFormatTypeSetUser * for how to update this later. * Deregisters a format type. * The caller must ensure that no other thread will be making use of any of * the dynamic formatting type facilities simultaneously with this call. * @returns IPRT status code. * @retval VINF_SUCCESS on success. * @retval VERR_FILE_NOT_FOUND if not found. * @param pszType The type to deregister. * Sets the user argument for a type. * This can be used if a user argument needs relocating in GC. * @returns IPRT status code. * @retval VINF_SUCCESS on success. * @retval VERR_FILE_NOT_FOUND if not found. * @param pszType The type to update. * @param pvUser The new user argument value. * @returns The length of the returned string (in pszBuffer). * @param pszBuffer Output buffer. * @param cchBuffer Size of the output buffer. * @param pszFormat The format string. * @param args The format argument. * @returns The length of the returned string (in pszBuffer). * @param pszBuffer Output buffer. * @param cchBuffer Size of the output buffer. * @param pszFormat The format string. * @param ... The format argument. * String printf with custom formatting. * @returns The length of the returned string (in pszBuffer). * @param pfnFormat Pointer to handler function for the custom formats. * @param pvArg Argument to the pfnFormat function. * @param pszBuffer Output buffer. * @param cchBuffer Size of the output buffer. * @param pszFormat The format string. * @param args The format argument. * String printf with custom formatting. * @returns The length of the returned string (in pszBuffer). * @param pfnFormat Pointer to handler function for the custom formats. * @param pvArg Argument to the pfnFormat function. * @param pszBuffer Output buffer. * @param cchBuffer Size of the output buffer. * @param pszFormat The format string. * @param ... The format argument. * Allocating string printf. * @returns The length of the string in the returned *ppszBuffer. * @returns -1 on failure. * @param ppszBuffer Where to store the pointer to the allocated output buffer. * The buffer should be freed using RTStrFree(). * On failure *ppszBuffer will be set to NULL. * @param pszFormat The format string. * @param args The format argument. * Allocating string printf. * @returns The length of the string in the returned *ppszBuffer. * @returns -1 on failure. * @param ppszBuffer Where to store the pointer to the allocated output buffer. * The buffer should be freed using RTStrFree(). * On failure *ppszBuffer will be set to NULL. * @param pszFormat The format string. * @param ... The format argument. * Strips blankspaces from both ends of the string. * @returns Pointer to first non-blank char in the string. * @param psz The string to strip. * Strips blankspaces from the start of the string. * @returns Pointer to first non-blank char in the string. * @param psz The string to strip. * Strips blankspaces from the end of the string. * @param psz The string to strip. * Performs a case sensitive string compare between two UTF-8 strings. * Encoding errors are ignored by the current implementation. So, the only * difference between this and the CRT strcmp function is the handling of * @returns < 0 if the first string less than the second string. * @returns 0 if the first string identical to the second string. * @returns > 0 if the first string greater than the second string. * @param psz1 First UTF-8 string. Null is allowed. * @param psz2 Second UTF-8 string. Null is allowed. * Performs a case sensitive string compare between two UTF-8 strings, given * a maximum string length. * Encoding errors are ignored by the current implementation. So, the only * difference between this and the CRT strncmp function is the handling of * @returns < 0 if the first string less than the second string. * @returns 0 if the first string identical to the second string. * @returns > 0 if the first string greater than the second string. * @param psz1 First UTF-8 string. Null is allowed. * @param psz2 Second UTF-8 string. Null is allowed. * @param cchMax The maximum string length * Performs a case insensitive string compare between two UTF-8 strings. * This is a simplified compare, as only the simplified lower/upper case folding * specified by the unicode specs are used. It does not consider character pairs * as they are used in some languages, just simple upper & lower case compares. * The result is the difference between the mismatching codepoints after they * both have been lower cased. * If the string encoding is invalid the function will assert (strict builds) * and use RTStrCmp for the remainder of the string. * @returns < 0 if the first string less than the second string. * @returns 0 if the first string identical to the second string. * @returns > 0 if the first string greater than the second string. * @param psz1 First UTF-8 string. Null is allowed. * @param psz2 Second UTF-8 string. Null is allowed. * Performs a case insensitive string compare between two UTF-8 strings, given a * This is a simplified compare, as only the simplified lower/upper case folding * specified by the unicode specs are used. It does not consider character pairs * as they are used in some languages, just simple upper & lower case compares. * The result is the difference between the mismatching codepoints after they * both have been lower cased. * If the string encoding is invalid the function will assert (strict builds) * and use RTStrCmp for the remainder of the string. * @returns < 0 if the first string less than the second string. * @returns 0 if the first string identical to the second string. * @returns > 0 if the first string greater than the second string. * @param psz1 First UTF-8 string. Null is allowed. * @param psz2 Second UTF-8 string. Null is allowed. * @param cchMax Maximum string length * Locates a case sensitive substring. * If any of the two strings are NULL, then NULL is returned. If the needle is * an empty string, then the haystack is returned (i.e. matches anything). * @returns Pointer to the first occurrence of the substring if found, NULL if * @param pszHaystack The string to search. * @param pszNeedle The substring to search for. * @remarks The difference between this and strstr is the handling of NULL * Locates a case insensitive substring. * If any of the two strings are NULL, then NULL is returned. If the needle is * an empty string, then the haystack is returned (i.e. matches anything). * @returns Pointer to the first occurrence of the substring if found, NULL if * @param pszHaystack The string to search. * @param pszNeedle The substring to search for. * Converts the string to lower case. * @returns Pointer to the converted string. * @param psz The string to convert. * Converts the string to upper case. * @returns Pointer to the converted string. * @param psz The string to convert. * Find the length of a zero-terminated byte string, given * @returns The string length or cbMax. The returned length does not include * the zero terminator if it was found. * @param pszString The string. * @param cchMax The max string length. * Find the length of a zero-terminated byte string, given * @returns IPRT status code. * @retval VINF_SUCCESS if the string has a length less than cchMax. * @retval VERR_BUFFER_OVERFLOW if the end of the string wasn't found * before cchMax was reached. * @param pszString The string. * @param cchMax The max string length. * @param pcch Where to store the string length excluding the * terminator. This is set to cchMax if the terminator * Matches a simple string pattern. * @returns true if the string matches the pattern, otherwise false. * @param pszPattern The pattern. Special chars are '*' and '?', where the * asterisk matches zero or more characters and question * mark matches exactly one character. * @param pszString The string to match against the pattern. * Matches a simple string pattern, neither which needs to be zero terminated. * This is identical to RTStrSimplePatternMatch except that you can optionally * specify the length of both the pattern and the string. The function will * stop when it hits a string terminator or either of the lengths. * @returns true if the string matches the pattern, otherwise false. * @param pszPattern The pattern. Special chars are '*' and '?', where the * asterisk matches zero or more characters and question * mark matches exactly one character. * @param cchPattern The pattern length. Pass RTSTR_MAX if you don't know the * length and wish to stop at the string terminator. * @param pszString The string to match against the pattern. * @param cchString The string length. Pass RTSTR_MAX if you don't know the * length and wish to match up to the string terminator. * Matches multiple patterns against a string. * The patterns are separated by the pipe character (|). * @returns true if the string matches the pattern, otherwise false. * @param pszPatterns The patterns. * @param cchPatterns The lengths of the patterns to use. Pass RTSTR_MAX to * stop at the terminator. * @param pszString The string to match against the pattern. * @param cchString The string length. Pass RTSTR_MAX stop stop at the * @param poffPattern Offset into the patterns string of the patttern that * matched. If no match, this will be set to RTSTR_MAX. * This is optional, NULL is fine. /** @defgroup rt_str_conv String To/From Number Conversions * Converts a string representation of a number to a 64-bit unsigned number. * @returns iprt status code. * Warnings are used to indicate conversion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VWRN_NEGATIVE_UNSIGNED * @retval VWRN_TRAILING_CHARS * @retval VWRN_TRAILING_SPACES * @param pszValue Pointer to the string value. * @param ppszNext Where to store the pointer to the first char following the number. (Optional) * @param uBase The base of the representation used. * If 0 the function will look for known prefixes before defaulting to 10. * @param pu64 Where to store the converted number. (optional) * Converts a string representation of a number to a 64-bit unsigned number, * making sure the full string is converted. * @returns iprt status code. * Warnings are used to indicate conversion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VWRN_NEGATIVE_UNSIGNED * @retval VERR_TRAILING_SPACES * @retval VERR_TRAILING_CHARS * @param pszValue Pointer to the string value. * @param uBase The base of the representation used. * If 0 the function will look for known prefixes before defaulting to 10. * @param pu64 Where to store the converted number. (optional) * Converts a string representation of a number to a 64-bit unsigned number. * @returns 64-bit unsigned number on success. * @param pszValue Pointer to the string value. * Converts a string representation of a number to a 32-bit unsigned number. * @returns iprt status code. * Warnings are used to indicate conversion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VWRN_NEGATIVE_UNSIGNED * @retval VWRN_TRAILING_CHARS * @retval VWRN_TRAILING_SPACES * @param pszValue Pointer to the string value. * @param ppszNext Where to store the pointer to the first char following the number. (Optional) * @param uBase The base of the representation used. * If 0 the function will look for known prefixes before defaulting to 10. * @param pu32 Where to store the converted number. (optional) * Converts a string representation of a number to a 32-bit unsigned number, * making sure the full string is converted. * @returns iprt status code. * Warnings are used to indicate conversion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VWRN_NEGATIVE_UNSIGNED * @retval VERR_TRAILING_SPACES * @retval VERR_TRAILING_CHARS * @param pszValue Pointer to the string value. * @param uBase The base of the representation used. * If 0 the function will look for known prefixes before defaulting to 10. * @param pu32 Where to store the converted number. (optional) * Converts a string representation of a number to a 64-bit unsigned number. * @returns 32-bit unsigned number on success. * @param pszValue Pointer to the string value. * Converts a string representation of a number to a 16-bit unsigned number. * @returns iprt status code. * Warnings are used to indicate conversion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VWRN_NEGATIVE_UNSIGNED * @retval VWRN_TRAILING_CHARS * @retval VWRN_TRAILING_SPACES * @param pszValue Pointer to the string value. * @param ppszNext Where to store the pointer to the first char following the number. (Optional) * @param uBase The base of the representation used. * If 0 the function will look for known prefixes before defaulting to 10. * @param pu16 Where to store the converted number. (optional) * Converts a string representation of a number to a 16-bit unsigned number, * making sure the full string is converted. * @returns iprt status code. * Warnings are used to indicate conversion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VWRN_NEGATIVE_UNSIGNED * @retval VERR_TRAILING_SPACES * @retval VERR_TRAILING_CHARS * @param pszValue Pointer to the string value. * @param uBase The base of the representation used. * If 0 the function will look for known prefixes before defaulting to 10. * @param pu16 Where to store the converted number. (optional) * Converts a string representation of a number to a 16-bit unsigned number. * @returns 16-bit unsigned number on success. * @param pszValue Pointer to the string value. * Converts a string representation of a number to a 8-bit unsigned number. * @returns iprt status code. * Warnings are used to indicate conversion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VWRN_NEGATIVE_UNSIGNED * @retval VWRN_TRAILING_CHARS * @retval VWRN_TRAILING_SPACES * @param pszValue Pointer to the string value. * @param ppszNext Where to store the pointer to the first char following the number. (Optional) * @param uBase The base of the representation used. * If 0 the function will look for known prefixes before defaulting to 10. * @param pu8 Where to store the converted number. (optional) * Converts a string representation of a number to a 8-bit unsigned number, * making sure the full string is converted. * @returns iprt status code. * Warnings are used to indicate conversion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VWRN_NEGATIVE_UNSIGNED * @retval VERR_TRAILING_SPACES * @retval VERR_TRAILING_CHARS * @param pszValue Pointer to the string value. * @param uBase The base of the representation used. * If 0 the function will look for known prefixes before defaulting to 10. * @param pu8 Where to store the converted number. (optional) * Converts a string representation of a number to a 8-bit unsigned number. * @returns 8-bit unsigned number on success. * @param pszValue Pointer to the string value. * Converts a string representation of a number to a 64-bit signed number. * @returns iprt status code. * Warnings are used to indicate conversion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VWRN_TRAILING_CHARS * @retval VWRN_TRAILING_SPACES * @param pszValue Pointer to the string value. * @param ppszNext Where to store the pointer to the first char following the number. (Optional) * @param uBase The base of the representation used. * If 0 the function will look for known prefixes before defaulting to 10. * @param pi64 Where to store the converted number. (optional) * Converts a string representation of a number to a 64-bit signed number, * making sure the full string is converted. * @returns iprt status code. * Warnings are used to indicate conversion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VERR_TRAILING_CHARS * @retval VERR_TRAILING_SPACES * @param pszValue Pointer to the string value. * @param uBase The base of the representation used. * If 0 the function will look for known prefixes before defaulting to 10. * @param pi64 Where to store the converted number. (optional) * Converts a string representation of a number to a 64-bit signed number. * @returns 64-bit signed number on success. * @param pszValue Pointer to the string value. * Converts a string representation of a number to a 32-bit signed number. * @returns iprt status code. * Warnings are used to indicate conversion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VWRN_TRAILING_CHARS * @retval VWRN_TRAILING_SPACES * @param pszValue Pointer to the string value. * @param ppszNext Where to store the pointer to the first char following the number. (Optional) * @param uBase The base of the representation used. * If 0 the function will look for known prefixes before defaulting to 10. * @param pi32 Where to store the converted number. (optional) * Converts a string representation of a number to a 32-bit signed number, * making sure the full string is converted. * @returns iprt status code. * Warnings are used to indicate conversion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VERR_TRAILING_CHARS * @retval VERR_TRAILING_SPACES * @param pszValue Pointer to the string value. * @param uBase The base of the representation used. * If 0 the function will look for known prefixes before defaulting to 10. * @param pi32 Where to store the converted number. (optional) * Converts a string representation of a number to a 32-bit signed number. * @returns 32-bit signed number on success. * @param pszValue Pointer to the string value. * Converts a string representation of a number to a 16-bit signed number. * @returns iprt status code. * Warnings are used to indicate conversion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VWRN_TRAILING_CHARS * @retval VWRN_TRAILING_SPACES * @param pszValue Pointer to the string value. * @param ppszNext Where to store the pointer to the first char following the number. (Optional) * @param uBase The base of the representation used. * If 0 the function will look for known prefixes before defaulting to 10. * @param pi16 Where to store the converted number. (optional) * Converts a string representation of a number to a 16-bit signed number, * making sure the full string is converted. * @returns iprt status code. * Warnings are used to indicate conversion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VERR_TRAILING_CHARS * @retval VERR_TRAILING_SPACES * @param pszValue Pointer to the string value. * @param uBase The base of the representation used. * If 0 the function will look for known prefixes before defaulting to 10. * @param pi16 Where to store the converted number. (optional) * Converts a string representation of a number to a 16-bit signed number. * @returns 16-bit signed number on success. * @param pszValue Pointer to the string value. * Converts a string representation of a number to a 8-bit signed number. * @returns iprt status code. * Warnings are used to indicate conversion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VWRN_TRAILING_CHARS * @retval VWRN_TRAILING_SPACES * @param pszValue Pointer to the string value. * @param ppszNext Where to store the pointer to the first char following the number. (Optional) * @param uBase The base of the representation used. * If 0 the function will look for known prefixes before defaulting to 10. * @param pi8 Where to store the converted number. (optional) * Converts a string representation of a number to a 8-bit signed number, * making sure the full string is converted. * @returns iprt status code. * Warnings are used to indicate conversion problems. * @retval VWRN_NUMBER_TOO_BIG * @retval VERR_TRAILING_CHARS * @retval VERR_TRAILING_SPACES * @param pszValue Pointer to the string value. * @param uBase The base of the representation used. * If 0 the function will look for known prefixes before defaulting to 10. * @param pi8 Where to store the converted number. (optional) * Converts a string representation of a number to a 8-bit signed number. * @returns 8-bit signed number on success. * @param pszValue Pointer to the string value. /** @defgroup rt_str_space Unique String Space /** Pointer to a string name space container node core. */ /** Pointer to a pointer to a string name space container node core. */ * String name space container node core. /** Hash key. Don't touch. */ /** Pointer to the left leaf node. Don't touch. */ /** Pointer to the left rigth node. Don't touch. */ /** Pointer to the list of string with the same key. Don't touch. */ /** Height of this tree: max(heigth(left), heigth(right)) + 1. Don't touch */ /** The string length. Read only! */ /** Pointer to the string. Read only! */ /** String space. (Initialize with NULL.) */ /** Pointer to a string space. */ * Inserts a string into a unique string space. * @returns true on success. * @returns false if the string collided with an existing string. * @param pStrSpace The space to insert it into. * @param pStr The string node. * Removes a string from a unique string space. * @returns Pointer to the removed string node. * @returns NULL if the string was not found in the string space. * @param pStrSpace The space to insert it into. * @param pszString The string to remove. * Gets a string from a unique string space. * @returns Pointer to the string node. * @returns NULL if the string was not found in the string space. * @param pStrSpace The space to insert it into. * @param pszString The string to get. * Callback function for RTStrSpaceEnumerate() and RTStrSpaceDestroy(). * @returns 0 on continue. * @returns Non-zero to aborts the operation. * @param pStr The string node * @param pvUser The user specified argument. /** Pointer to callback function for RTStrSpaceEnumerate() and RTStrSpaceDestroy(). */ * Destroys the string space. * The caller supplies a callback which will be called for each of * the string nodes in for freeing their memory and other resources. * @returns 0 or what ever non-zero return value pfnCallback returned * when aborting the destruction. * @param pStrSpace The space to insert it into. * @param pfnCallback The callback. * @param pvUser The user argument. * Enumerates the string space. * The caller supplies a callback which will be called for each of * @returns 0 or what ever non-zero return value pfnCallback returned * when aborting the destruction. * @param pStrSpace The space to insert it into. * @param pfnCallback The callback. * @param pvUser The user argument. /** @defgroup rt_str_utf16 UTF-16 String Manipulation * Free a UTF-16 string allocated by RTStrUtf8ToUtf16(), RTStrUtf8ToUtf16Ex(), * RTUtf16Dup() or RTUtf16DupEx(). * @returns iprt status code. * @param pwszString The UTF-16 string to free. NULL is accepted. * Allocates a new copy of the specified UTF-16 string. * @returns Pointer to the allocated string copy. Use RTUtf16Free() to free it. * @returns NULL when out of memory. * @param pwszString UTF-16 string to duplicate. * @remark This function will not make any attempt to validate the encoding. * Allocates a new copy of the specified UTF-16 string. * @returns iprt status code. * @param ppwszString Receives pointer of the allocated UTF-16 string. * The returned pointer must be freed using RTUtf16Free(). * @param pwszString UTF-16 string to duplicate. * @param cwcExtra Number of extra RTUTF16 items to allocate. * @remark This function will not make any attempt to validate the encoding. * Returns the length of a UTF-16 string in UTF-16 characters * without trailing '\\0'. * Surrogate pairs counts as two UTF-16 characters here. Use RTUtf16CpCnt() * to get the exact number of code points in the string. * @returns The number of RTUTF16 items in the string. * @param pwszString Pointer the UTF-16 string. * @remark This function will not make any attempt to validate the encoding. * Performs a case sensitive string compare between two UTF-16 strings. * @returns < 0 if the first string less than the second string.s * @returns 0 if the first string identical to the second string. * @returns > 0 if the first string greater than the second string. * @param pwsz1 First UTF-16 string. Null is allowed. * @param pwsz2 Second UTF-16 string. Null is allowed. * @remark This function will not make any attempt to validate the encoding. * Performs a case insensitive string compare between two UTF-16 strings. * This is a simplified compare, as only the simplified lower/upper case folding * specified by the unicode specs are used. It does not consider character pairs * as they are used in some languages, just simple upper & lower case compares. * @returns < 0 if the first string less than the second string. * @returns 0 if the first string identical to the second string. * @returns > 0 if the first string greater than the second string. * @param pwsz1 First UTF-16 string. Null is allowed. * @param pwsz2 Second UTF-16 string. Null is allowed. * Performs a case insensitive string compare between two UTF-16 strings * using the current locale of the process (if applicable). * This differs from RTUtf16ICmp() in that it will try, if a locale with the * required data is available, to do a correct case-insensitive compare. It * follows that it is more complex and thereby likely to be more expensive. * @returns < 0 if the first string less than the second string. * @returns 0 if the first string identical to the second string. * @returns > 0 if the first string greater than the second string. * @param pwsz1 First UTF-16 string. Null is allowed. * @param pwsz2 Second UTF-16 string. Null is allowed. * Folds a UTF-16 string to lowercase. * This is a very simple folding; is uses the simple lowercase * code point, it is not related to any locale just the most common * lowercase codepoint setup by the unicode specs, and it will not * create new surrogate pairs or remove existing ones. * @returns Pointer to the passed in string. * @param pwsz The string to fold. * Folds a UTF-16 string to uppercase. * This is a very simple folding; is uses the simple uppercase * code point, it is not related to any locale just the most common * uppercase codepoint setup by the unicode specs, and it will not * create new surrogate pairs or remove existing ones. * @returns Pointer to the passed in string. * @param pwsz The string to fold. * Translate a UTF-16 string into a UTF-8 allocating the result buffer. * @returns iprt status code. * @param pwszString UTF-16 string to convert. * @param ppszString Receives pointer of allocated UTF-8 string on * success, and is always set to NULL on failure. * The returned pointer must be freed using RTStrFree(). * Translates UTF-16 to UTF-8 using buffer provided by the caller or * a fittingly sized buffer allocated by the function. * @returns iprt status code. * @param pwszString The UTF-16 string to convert. * @param cwcString The number of RTUTF16 items to translate from pwszString. * The translation will stop when reaching cwcString or the terminator ('\\0'). * Use RTSTR_MAX to translate the entire string. * @param ppsz If cch is non-zero, this must either be pointing to a pointer to * a buffer of the specified size, or pointer to a NULL pointer. * If *ppsz is NULL or cch is zero a buffer of at least cch chars * will be allocated to hold the translated string. * If a buffer was requested it must be freed using RTUtf16Free(). * @param cch The buffer size in chars (the type). This includes the terminator. * @param pcch Where to store the length of the translated string. (Optional) * This field will be updated even on failure, however the value is only * specified for the following two error codes. On VERR_BUFFER_OVERFLOW * and VERR_NO_STR_MEMORY it contains the required buffer space. * Calculates the length of the UTF-16 string in UTF-8 chars (bytes). * This function will validate the string, and incorrectly encoded UTF-16 * strings will be rejected. The primary purpose of this function is to * help allocate buffers for RTUtf16ToUtf8() of the correct size. For most * other purposes RTUtf16ToUtf8Ex() should be used. * @returns Number of char (bytes). * @returns 0 if the string was incorrectly encoded. * @param pwsz The UTF-16 string. * Calculates the length of the UTF-16 string in UTF-8 chars (bytes). * This function will validate the string, and incorrectly encoded UTF-16 * strings will be rejected. * @returns iprt status code. * @param pwsz The string. * @param cwc The max string length. Use RTSTR_MAX to process the entire string. * @param pcch Where to store the string length (in bytes). Optional. * This is undefined on failure. * Get the unicode code point at the given string position. * @returns unicode code point. * @returns RTUNICP_INVALID if the encoding is invalid. * @param pwsz The string. * @remark This is an internal worker for RTUtf16GetCp(). * Get the unicode code point at the given string position. * @returns iprt status code. * @param ppwsz Pointer to the string pointer. This will be updated to * point to the char following the current code point. * @param pCp Where to store the code point. * RTUNICP_INVALID is stored here on failure. * @remark This is an internal worker for RTUtf16GetCpEx(). * Put the unicode code point at the given string position * and return the pointer to the char following it. * This function will not consider anything at or following the * buffer area pointed to by pwsz. It is therefore not suitable for * @returns pointer to the char following the written code point. * @param pwsz The string. * @param CodePoint The code point to write. * This should not be RTUNICP_INVALID or any other * character out of the UTF-16 range. * @remark This is an internal worker for RTUtf16GetCpEx(). * Get the unicode code point at the given string position. * @returns unicode code point. * @returns RTUNICP_INVALID if the encoding is invalid. * @param pwsz The string. * @remark We optimize this operation by using an inline function for * everything which isn't a surrogate pair or an endian indicator. if (
wc <
0xd800 || (
wc >
0xdfff &&
wc <
0xfffe))
* Get the unicode code point at the given string position. * @returns iprt status code. * @param ppwsz Pointer to the string pointer. This will be updated to * point to the char following the current code point. * @param pCp Where to store the code point. * RTUNICP_INVALID is stored here on failure. * @remark We optimize this operation by using an inline function for * everything which isn't a surrogate pair or and endian indicator. if (
wc <
0xd800 || (
wc >
0xdfff &&
wc <
0xfffe))
* Put the unicode code point at the given string position * and return the pointer to the char following it. * This function will not consider anything at or following the * buffer area pointed to by pwsz. It is therefore not suitable for * @returns pointer to the char following the written code point. * @param pwsz The string. * @param CodePoint The code point to write. * This should not be RTUNICP_INVALID or any other * character out of the UTF-16 range. * @remark We optimize this operation by using an inline function for * everything which isn't a surrogate pair or and endian indicator. * Skips ahead, past the current code point. * @returns Pointer to the char after the current code point. * @param pwsz Pointer to the current code point. * @remark This will not move the next valid code point, only past the current one. * Skips backwards, to the previous code point. * @returns Pointer to the char after the current code point. * @param pwszStart Pointer to the start of the string. * @param pwsz Pointer to the current code point. * Checks if the UTF-16 char is the high surrogate char (i.e. * the 1st char in the pair). * @returns true if it is. * @returns false if it isn't. * @param wc The character to investigate. return wc >=
0xd800 &&
wc <=
0xdbff;
* Checks if the UTF-16 char is the low surrogate char (i.e. * the 2nd char in the pair). * @returns true if it is. * @returns false if it isn't. * @param wc The character to investigate. return wc >=
0xdc00 &&
wc <=
0xdfff;
* Checks if the two UTF-16 chars form a valid surrogate pair. * @returns true if they do. * @returns false if they doesn't. * @param wcHigh The high (1st) character. * @param wcLow The low (2nd) character.