UTF-8 aware character functions.
s_getc | Read the first character from a UTF-8 string. |
s_getx | Read the first character from a UTF-8 string, advancing the pointer position. |
s_getat | Return the character from the specified index within the UTF-8 string. |
s_setc | Set a character in a UTF-8 string and return the byte size of the character. |
s_setat | Modify the character at the specified index within the UTF-8 string, handling adjustments for variable width data. |
s_width | Return the width (number of bytes) of the first UTF-8 character in the given string. |
s_cwidth | Return the width (number of bytes) of a UTF-8 character represented by the given 4-byte unsigned integer. |
s_offset | Return the offset in bytes from the start of the UTF-8 string to the character at the specified index. |
s_insert | Insert a character at the specified index within a UTF-8 string, sliding following data along to make room. |
s_remove | Remove the character at the specified index within the UTF-8 string, sliding following data back to make room. |
s_tolower | Convert the given UTF-8 character to lower case. |
s_toupper | Convert the given UTF-8 character to upper case. |
s_isspace | Check whether the given UTF-8 character is a white-space. |
s_isdigit | Check whether the given UTF-8 character is a digit. |
Read the first character from a UTF-8 string.
Parameters: |
|
---|---|
Return: | UTF8 character represented as a 4-byte unsigned integer. |
Read the first character from a UTF-8 string, advancing the pointer position.
Parameters: |
|
---|---|
Return: | UTF8 character represented as a 4-byte unsigned integer. |
Note: | The original pointer is lost if it is not saved somewhere else. |
Set a character in a UTF-8 string and return the byte size of the character.
Parameters: |
|
---|---|
Return: | The byte size of the character. |
Modify the character at the specified index within the UTF-8 string, handling adjustments for variable width data.
Returns how far the rest of the string was moved in bytes. Indexing in strings start at 0.
Parameters: |
|
---|---|
Return: | Number of bytes the string was moved. |
Return the width (number of bytes) of the first UTF-8 character in the given string.
Parameters: |
|
---|---|
Return: | The byte width of the first character in the string. |
Return the offset in bytes from the start of the UTF-8 string to the character at the specified index.
If the index is negative, counts backward from the end of the string (-1 returns an offset to the last character).
Parameters: |
|
---|---|
Return: | The byte offset of the character at index in s. |
Insert a character at the specified index within a UTF-8 string, sliding following data along to make room.
Returns how far the data was moved in bytes.
Parameters: |
|
---|---|
Return: | The amount of bytes the string was moved. |
Note: | The given string s must be big enough to take inserted character, no checking is done. |
Remove the character at the specified index within the UTF-8 string, sliding following data back to make room.
Returns how far the data was moved in bytes.
Parameters: |
|
---|---|
Return: | The amount of bytes the string was moved. |
Check whether the given UTF-8 character is a white-space.
White-space is space (‘ ‘), form-feed (‘\f’), newline (‘\n’), carriage return (‘\r’), horizontal tab (‘\t’), and vertical tab (‘\v’).
Parameters: |
|
---|---|
Return: | Non-zero if c is a white-space otherwise 0. |