feat: add raw byte access methods and \x escape to String class

Add `byteAt(index)`, `codePointAt(index)`, and `bytes` sequence to String,
enabling direct byte-level manipulation of UTF-8 encoded strings. Introduce
`\x` hex escape sequence in string literals for specifying raw byte values.
Refactor Unicode escape parsing into a generic `readHexEscape` function
supporting variable digit counts. Implement `wrenUtf8Decode` utility for
decoding UTF-8 sequences from byte buffers. Add comprehensive tests for
`byteAt` including boundary conditions and error cases.
This commit is contained in:
Bob Nystrom
2015-03-28 03:44:07 +00:00
parent b7904a89c9
commit c3d0b66630
36 changed files with 402 additions and 15 deletions
+13 -1
View File
@@ -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) {