|
Drag[en]gine Script Module DragonScript 1.32.1
|
Navigate UTF-8 encoded string. More...
Public Member Functions | |
| UTF8Navigator | atEnd () |
| New navigator with position set to end of string. | |
| UTF8Navigator | atStart () |
| New navigator with position set to start of string. | |
| void | backward () |
| Move one character towards start of the string. | |
| void | backward (int count) |
| Move multiple characters towards start of the string. | |
| int | countCharacters () |
| Count characters from start of string to current position. | |
| int | countCharactersEnd () |
| Count characters from current position to end of string. | |
| int | decodeCharacter () |
| Decode UTF-8 character at position. | |
| void | forward () |
| Move one character towards end of the string. | |
| void | forward (int count) |
| Move multiple characters towards end of the string. | |
| int | getCharacterCount () |
| Count of characters in string. | |
| int | getLength () |
| Length of string in bytes. | |
| int | getPosition () |
| Position in bytes. | |
| String | getString () |
| String to navigate. | |
| bool | isAtEnd () |
| Position is at end of string. | |
| bool | isAtStart () |
| Position is at start of string. | |
| void | move (int count) |
| Move multiple characters. | |
| UTF8Navigator | new (String string) |
| Create navigator. | |
| UTF8Navigator | new (String string, int position) |
| Create navigator with position. | |
| UTF8Navigator | new (UTF8Navigator navigator) |
| Create copy of navigator. | |
| UTF8Navigator | new (UTF8Navigator navigator, int position) |
| Create copy of navigator with new position. | |
| UTF8Navigator | operator+ (int count) |
| New navigator with moving multiple characters. | |
| UTF8Navigator | operator- (int count) |
| New navigator with moving multiple characters. | |
| void | setCharacterPosition (int position) |
| Set position in bytes matching character position clamped to valid range. | |
| void | setFrom (UTF8Navigator navigator) |
| Set navigator from another navigator. | |
| void | setPosition (int position) |
| Set position in bytes clamped to valid range. | |
| void | setPositionBegin () |
| Set position to start of string. | |
| void | setPositionEnd () |
| Set position to end of string. | |
| void | setString (String string) |
| Set string to navigate. | |
Navigate UTF-8 encoded string.
Stores the string and position in bytes from the start of the string. The position moves forward and backward in a way it always stops at the first byte of a UTF-8 character. The following table illustrates the possible UTF-8 byte values:
^ Byte 1 ^ Byte 2 ^ Byte 3 ^ Byte 4 ^ | 0xxxxxxx | - | - | - | | 110xxxxx | 10xxxxxx | - | - | | 1110xxxx | 10xxxxxx | 10xxxxxx | - | | 11110xxx | 10xxxxxx | 10xxxxxx | 10xxxxxx |
Hence all bytes with the high bits 10 are following bytes and can be skipped.
In addition to moving by UTF-8 character it is also possible to count the characters from the begin of the string to the current position. This allows to properly position a cursor using the character position.
| UTF8Navigator Dragengine.Utils.UTF8Navigator.atEnd | ( | ) |
New navigator with position set to end of string.
| UTF8Navigator Dragengine.Utils.UTF8Navigator.atStart | ( | ) |
New navigator with position set to start of string.
| void Dragengine.Utils.UTF8Navigator.backward | ( | ) |
Move one character towards start of the string.
| void Dragengine.Utils.UTF8Navigator.backward | ( | int | count | ) |
Move multiple characters towards start of the string.
| int Dragengine.Utils.UTF8Navigator.countCharacters | ( | ) |
Count characters from start of string to current position.
| int Dragengine.Utils.UTF8Navigator.countCharactersEnd | ( | ) |
Count characters from current position to end of string.
| int Dragengine.Utils.UTF8Navigator.decodeCharacter | ( | ) |
Decode UTF-8 character at position.
If the position is at the end of string or the UTF-8 character is invalid -1 is returned.
| void Dragengine.Utils.UTF8Navigator.forward | ( | ) |
Move one character towards end of the string.
| void Dragengine.Utils.UTF8Navigator.forward | ( | int | count | ) |
Move multiple characters towards end of the string.
| int Dragengine.Utils.UTF8Navigator.getCharacterCount | ( | ) |
Count of characters in string.
| int Dragengine.Utils.UTF8Navigator.getLength | ( | ) |
Length of string in bytes.
| int Dragengine.Utils.UTF8Navigator.getPosition | ( | ) |
Position in bytes.
| String Dragengine.Utils.UTF8Navigator.getString | ( | ) |
String to navigate.
| bool Dragengine.Utils.UTF8Navigator.isAtEnd | ( | ) |
Position is at end of string.
| bool Dragengine.Utils.UTF8Navigator.isAtStart | ( | ) |
Position is at start of string.
| void Dragengine.Utils.UTF8Navigator.move | ( | int | count | ) |
Move multiple characters.
If count is positive moves towards the end of string. If count is negative moves towards the start of string. Does nothing if count is 0.
| UTF8Navigator Dragengine.Utils.UTF8Navigator.new | ( | String | string | ) |
Create navigator.
| UTF8Navigator Dragengine.Utils.UTF8Navigator.new | ( | String | string, |
| int | position | ||
| ) |
Create navigator with position.
| UTF8Navigator Dragengine.Utils.UTF8Navigator.new | ( | UTF8Navigator | navigator | ) |
Create copy of navigator.
| UTF8Navigator Dragengine.Utils.UTF8Navigator.new | ( | UTF8Navigator | navigator, |
| int | position | ||
| ) |
Create copy of navigator with new position.
| UTF8Navigator Dragengine.Utils.UTF8Navigator.operator+ | ( | int | count | ) |
New navigator with moving multiple characters.
| UTF8Navigator Dragengine.Utils.UTF8Navigator.operator- | ( | int | count | ) |
New navigator with moving multiple characters.
| void Dragengine.Utils.UTF8Navigator.setCharacterPosition | ( | int | position | ) |
Set position in bytes matching character position clamped to valid range.
| void Dragengine.Utils.UTF8Navigator.setFrom | ( | UTF8Navigator | navigator | ) |
Set navigator from another navigator.
| void Dragengine.Utils.UTF8Navigator.setPosition | ( | int | position | ) |
Set position in bytes clamped to valid range.
If position is not at valid first byte moves backward until valid first first byte.
| void Dragengine.Utils.UTF8Navigator.setPositionBegin | ( | ) |
Set position to start of string.
| void Dragengine.Utils.UTF8Navigator.setPositionEnd | ( | ) |
Set position to end of string.
| void Dragengine.Utils.UTF8Navigator.setString | ( | String | string | ) |
Set string to navigate.
Sets position to 0.