|
Bond 0.9
Bond Standard Library API Documentation
|
A collection of functions for manipulating strings of characters. More...
Functions | |
| uint | Bond::Strlen (const char *str) |
| Returns the length of a string in bytes, not in characters. | |
| int | Bond::Strcmp (const char *str1, const char *str2) |
| Compares two strings byte by byte. For UTF-8 strings, this orders them by code point. The order is stable, but it is not a locale's collation order. | |
| uint | Bond::Utf8Length (const char *str) |
| Returns the number of code points in a UTF-8 string. Each invalid byte sequence counts as one, as if it were replaced with U+FFFD. | |
| bool | Bond::Utf8IsValid (const char *str) |
| Returns whether a string is valid UTF-8. Overlong encodings, UTF-16 surrogates and values beyond U+10FFFF are invalid. | |
| uint | Bond::Utf8Decode (const char *str, uint *codePoint) |
| Decodes the UTF-8 encoded code point at the start of a string. | |
| uint | Bond::Utf8Encode (uint codePoint, char *buffer) |
| Encodes a code point in UTF-8. | |
| bool | Bond::TryParseInt (const char *str, int *result) |
| Parses a base-10 integer from the start of a string as an int. | |
| bool | Bond::TryParseLong (const char *str, long *result) |
| Parses a base-10 integer from the start of a string as a long. | |
| bool | Bond::TryParseFloat (const char *str, float *result) |
| Parses a floating-point number from the start of a string as a float. | |
| bool | Bond::TryParseDouble (const char *str, double *result) |
| Parses a floating-point number from the start of a string as a double. | |
A collection of functions for manipulating strings of characters.
Strings are null-terminated and encoded in UTF-8. A char holds a single byte, which is one UTF-8 code unit rather than one character. The Utf8 functions operate on code points.
| int Bond::Strcmp | ( | const char * | str1, |
| const char * | str2 ) |
Compares two strings byte by byte. For UTF-8 strings, this orders them by code point. The order is stable, but it is not a locale's collation order.
| str1 | The first string to compare. |
| str2 | The second string to compare. |
| uint Bond::Strlen | ( | const char * | str | ) |
Returns the length of a string in bytes, not in characters.
| str | The string whose length is returned. |
| bool Bond::TryParseDouble | ( | const char * | str, |
| double * | result ) |
Parses a floating-point number from the start of a string as a double.
Leading whitespace is skipped, and any characters after the number are ignored. The accepted syntax is that of the C library's strtod, which depends on the C locale unless the host has replaced the parser. A value out of the range of a double is not an error: it is parsed as infinity or zero.
| str | The string to parse. |
| result | Receives the parsed value on success. It is left unchanged on failure. |
| bool Bond::TryParseFloat | ( | const char * | str, |
| float * | result ) |
Parses a floating-point number from the start of a string as a float.
Leading whitespace is skipped, and any characters after the number are ignored. The accepted syntax is that of the C library's strtof, which depends on the C locale unless the host has replaced the parser. A value out of the range of a float is not an error: it is parsed as infinity or zero.
| str | The string to parse. |
| result | Receives the parsed value on success. It is left unchanged on failure. |
| bool Bond::TryParseInt | ( | const char * | str, |
| int * | result ) |
Parses a base-10 integer from the start of a string as an int.
Leading whitespace is skipped, and any characters after the number are ignored.
| str | The string to parse. |
| result | Receives the parsed value on success. It is left unchanged on failure. |
| bool Bond::TryParseLong | ( | const char * | str, |
| long * | result ) |
Parses a base-10 integer from the start of a string as a long.
Leading whitespace is skipped, and any characters after the number are ignored.
| str | The string to parse. |
| result | Receives the parsed value on success. It is left unchanged on failure. |
| uint Bond::Utf8Decode | ( | const char * | str, |
| uint * | codePoint ) |
Decodes the UTF-8 encoded code point at the start of a string.
| str | The string to decode. |
| codePoint | Receives the decoded code point, or U+FFFD if the sequence is invalid. May be null to skip over a code point without reading it. |
| uint Bond::Utf8Encode | ( | uint | codePoint, |
| char * | buffer ) |
Encodes a code point in UTF-8.
| codePoint | The code point to encode. |
| buffer | Receives from 1 to 4 bytes, without a null terminator. May be null to just compute the length. |
| bool Bond::Utf8IsValid | ( | const char * | str | ) |
Returns whether a string is valid UTF-8. Overlong encodings, UTF-16 surrogates and values beyond U+10FFFF are invalid.
| str | The string to validate. |
| uint Bond::Utf8Length | ( | const char * | str | ) |
Returns the number of code points in a UTF-8 string. Each invalid byte sequence counts as one, as if it were replaced with U+FFFD.
| str | The string whose length is returned. |