Defines | |
#define | ur_cstr(strC, bin) ur_cstring(ur_bufferSer(strC), bin, strC->series.it, strC->series.end) |
Make null terminated UTF-8 string in binary buffer. | |
#define | ur_strFree ur_arrFree |
A string is a simple array. | |
Functions | |
UIndex | ur_makeString (UThread *ut, int enc, int size) |
Generate and initialize a single string buffer. | |
UBuffer * | ur_makeStringCell (UThread *ut, int enc, int size, UCell *cell) |
Generate a single string and set cell to reference it. | |
UIndex | ur_makeStringUtf8 (UThread *ut, const uint8_t *it, const uint8_t *end) |
Generate and initialize a single string buffer from memory holding a UTF-8 string. | |
void | ur_strInit (UBuffer *buf, int enc, int size) |
Initialize buffer to type UT_STRING. | |
void | ur_strAppendChar (UBuffer *str, int uc) |
Append a single UCS2 character to a string. | |
void | ur_strAppendCStr (UBuffer *str, const char *cstr) |
Append a null-terminated ASCII string to a string buffer. | |
void | ur_strAppendInt (UBuffer *str, int32_t n) |
Append an integer to a string. | |
void | ur_strAppendInt64 (UBuffer *str, int64_t n) |
Append an 64-bit integer to a string. | |
void | ur_strAppendHex (UBuffer *str, uint32_t n, uint32_t hi) |
Append a hexidecimal integer to a string. | |
void | ur_strAppendDouble (UBuffer *str, double n) |
Append a double to a string. | |
void | ur_strAppendIndent (UBuffer *str, int depth) |
Append tabs to a string. | |
void | ur_strAppend (UBuffer *str, const UBuffer *strB, UIndex itB, UIndex endB) |
Append another string buffer to this string. | |
void | ur_strTermNull (UBuffer *str) |
Terminate with null character so buffer can be used as a C string. | |
int | ur_strIsAscii (const UBuffer *str) |
Test if all characters are ASCII. | |
void | ur_strFlatten (UBuffer *str) |
Convert a UTF-8 or UCS-2 string buffer to Latin-1 if possible. | |
void | ur_strLowercase (UBuffer *buf, UIndex start, UIndex send) |
Convert characters of string slice to lowercase. | |
void | ur_strUppercase (UBuffer *buf, UIndex start, UIndex send) |
Convert characters of string slice to uppercase. | |
int | ur_charLowercase (int c) |
Convert UCS2 character to lowercase. | |
int | ur_charUppercase (int c) |
Convert UCS2 character to uppercase. | |
UIndex | ur_strFindChar (const UBuffer *str, UIndex start, UIndex end, int ch) |
Find the first instance of a character in a string. | |
UIndex | ur_strFindChars (const UBuffer *str, UIndex start, UIndex end, uint8_t *charSet, int len) |
Find the first character of a set in a string. | |
UIndex | ur_strFind (const USeriesIter *ai, const USeriesIter *bi, int matchCase) |
Find string in another string. | |
UIndex | ur_strMatch (const USeriesIter *ai, const USeriesIter *bi, int matchCase) |
Compare characters in two strings. | |
int | ur_strChar (const UBuffer *str, UIndex pos) |
Return the character at a given position. | |
char * | ur_cstring (const UBuffer *str, UBuffer *bin, UIndex start, UIndex end) |
Make null terminated UTF-8 string in binary buffer. |
UTF-8 (UR_ENC_UTF8) is only handled by ur_strAppend() and ur_makeStringUtf8() in order to bring UTF-8 strings into or out of the datatype system.
#define ur_cstr | ( | strC, | |||
bin | ) | ur_cstring(ur_bufferSer(strC), bin, strC->series.it, strC->series.end) |
Make null terminated UTF-8 string in binary buffer.
This calls ur_cstring().
strC | Valid UT_STRING or UT_FILE cell. | |
bin | Initialized binary buffer to use. |
Make null terminated UTF-8 string in binary buffer.
str | Valid string buffer. | |
bin | Initialized binary buffer. The contents are replaced with the C string. | |
start | Start position in str. | |
end | End position in str. A negative number is the same as str->used. |
UIndex ur_makeString | ( | UThread * | ut, | |
int | enc, | |||
int | size | |||
) |
Generate and initialize a single string buffer.
If you need multiple buffers then ur_genBuffers() should be used.
The caller must create a UCell for this string in a held block before the next ur_recycle() or else it will be garbage collected.
enc | Encoding type. | |
size | Number of characters to reserve. |
Generate a single string and set cell to reference it.
If you need multiple buffers then ur_genBuffers() should be used.
enc | Encoding type. | |
size | Number of characters to reserve. | |
cell | Cell to initialize. |
UIndex ur_makeStringUtf8 | ( | UThread * | ut, | |
const uint8_t * | it, | |||
const uint8_t * | end | |||
) |
Generate and initialize a single string buffer from memory holding a UTF-8 string.
This calls ur_makeString() internally.
it | Start of UTF-8 data. | |
end | End of UTF-8 data. |
Append another string buffer to this string.
str | Destination string. | |
strB | String to append. | |
itB | Start character of strB. | |
endB | End character of strB. |
void ur_strAppendIndent | ( | UBuffer * | str, | |
int | depth | |||
) |
Append tabs to a string.
depth | Number of tabs to append. |
int ur_strChar | ( | const UBuffer * | str, | |
UIndex | pos | |||
) |
Return the character at a given position.
If the str->form is UR_ENC_UTF8, then the return value will be the byte at pos, not the UCS2 character.
str | Valid string buffer. | |
pos | Character index. Pass negative numbers to index from the end (e.g. -1 will return the last character). |
UIndex ur_strFind | ( | const USeriesIter * | ai, | |
const USeriesIter * | bi, | |||
int | matchCase | |||
) |
Find string in another string.
ai | String to search. | |
bi | Pattern to look for. | |
matchCase | If non-zero, compare character cases. |
UIndex ur_strFindChar | ( | const UBuffer * | str, | |
UIndex | start, | |||
UIndex | end, | |||
int | ch | |||
) |
Find the first instance of a character in a string.
str | Valid string buffer. | |
start | Start index in str. | |
end | Ending index in str. | |
ch | Bitset of characters to look for. |
UIndex ur_strFindChars | ( | const UBuffer * | str, | |
UIndex | start, | |||
UIndex | end, | |||
uint8_t * | charSet, | |||
int | len | |||
) |
Find the first character of a set in a string.
str | Valid string buffer. | |
start | Start index in str. | |
end | Ending index in str. | |
charSet | Bitset of characters to look for. | |
len | Byte length of charSet. |
void ur_strFlatten | ( | UBuffer * | str | ) |
Convert a UTF-8 or UCS-2 string buffer to Latin-1 if possible.
str | Valid string buffer. |
void ur_strInit | ( | UBuffer * | buf, | |
int | enc, | |||
int | size | |||
) |
Initialize buffer to type UT_STRING.
enc | Encoding type. | |
size | Number of characters to reserve. |
int ur_strIsAscii | ( | const UBuffer * | str | ) |
Test if all characters are ASCII.
str | Valid string buffer. |
void ur_strLowercase | ( | UBuffer * | buf, | |
UIndex | start, | |||
UIndex | send | |||
) |
Convert characters of string slice to lowercase.
buf | Pointer to valid string buffer. | |
start | Start position. | |
send | Slice end position. |
UIndex ur_strMatch | ( | const USeriesIter * | ai, | |
const USeriesIter * | bi, | |||
int | matchCase | |||
) |
Compare characters in two strings.
ai | String slice A. | |
bi | String slice B. | |
matchCase | If non-zero, compare character cases. |
void ur_strTermNull | ( | UBuffer * | str | ) |
Terminate with null character so buffer can be used as a C string.
Str->used is not changed.
void ur_strUppercase | ( | UBuffer * | buf, | |
UIndex | start, | |||
UIndex | send | |||
) |
Convert characters of string slice to uppercase.
buf | Pointer to valid string buffer. | |
start | Start position. | |
send | Slice end position. |