feat: add StringCodePointSequence class and expose codePoints property on String
Extract codePointAt() logic into a dedicated StringCodePointSequence class that wraps a string and implements the Sequence interface, enabling iteration over code points. Add a `codePoints` getter to String that returns a new instance of this sequence. Refactor the underlying C implementation of `codePointAt_` to decode UTF-8 into actual code point integers (returning raw bytes for invalid sequences) and rename the primitive to use trailing underscore convention. Update all related tests to reflect the new behavior where mid-sequence byte indices return the raw byte string instead of an empty string, and add new test files for the code point sequence iteration.
This commit is contained in:
@@ -45,20 +45,6 @@ It is a runtime error if `codePoint` is not an integer between `0` and
|
||||
|
||||
## Methods
|
||||
|
||||
### **byteAt**(index)
|
||||
|
||||
Gets the value of the byte at byte offset `index` in the string.
|
||||
|
||||
:::dart
|
||||
IO.print("hello".byteAt(1)) // 101, for "e".
|
||||
|
||||
If the index is negative, it counts backwards from the end of the string.
|
||||
|
||||
:::dart
|
||||
IO.print("hello".byteAt(-4)) // 101, for "e".
|
||||
|
||||
It is a runtime error if `index` is not an integer or is out of bounds.
|
||||
|
||||
### **bytes**
|
||||
|
||||
Gets a [`Sequence`](sequence.html) that can be used to access the raw bytes of
|
||||
|
||||
Reference in New Issue
Block a user