More stuff for working with strings and bytes!
- "\x" escape sequence to put byte values in strings: "\x34" - String.byteAt(index) gets value of byte in string. - String.bytes returns a raw sequence of bytes for a string. - String.codePointAt(index) gets the code point at an offset as a raw number.
This commit is contained in:
+13
-1
@@ -92,7 +92,19 @@ class Sequence {
|
||||
}
|
||||
}
|
||||
|
||||
class String is Sequence {}
|
||||
class String is Sequence {
|
||||
bytes { new StringByteSequence(this) }
|
||||
}
|
||||
|
||||
class StringByteSequence is Sequence {
|
||||
new(string) {
|
||||
_string = string
|
||||
}
|
||||
|
||||
[index] { _string.byteAt(index) }
|
||||
iterate(iterator) { _string.iterateByte_(iterator) }
|
||||
iteratorValue(iterator) { _string.byteAt(iterator) }
|
||||
}
|
||||
|
||||
class List is Sequence {
|
||||
addAll(other) {
|
||||
|
||||
Reference in New Issue
Block a user