-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* More chars support Now that the compiler can support Char literals, more features can be added including a chars iterator for strings. * UTF-8 encoding/decoding The implementation of `CharsIterator` now also supports multi-byte UTF-8 decoding. I also added a `Char#bytes` method to convert the u32 representation of the character codepoint into the required number of bytes for proper UTF-8 encoding. * Renaming 'CharIterator' to 'CharsIterator'
- Loading branch information
Showing
8 changed files
with
148 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
val x = 'a' | ||
println(x) | ||
val chars = "a£→😀".chars() | ||
|
||
val t = x == 'a' | ||
val f = x == 'A' | ||
println(t, f) | ||
/// Expect: a 97 [0b1100001] | ||
/// Expect: £ 163 [0b11000010, 0b10100011] | ||
/// Expect: → 65515 [0b11101111, 0b10111111, 0b10101011] | ||
/// Expect: 😀 128512 [0b11110000, 0b10011111, 0b10011000, 0b10000000] | ||
for ch in chars { | ||
println(ch, ch.asInt(), ch.bytes().map(b => b.binary())) | ||
} | ||
|
||
val h = 'a'.hash() | ||
println(h) | ||
|
||
println(x.asInt()) | ||
val ch = Char.fromInt(0xD800) | ||
/// Expect: � | ||
println(ch) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters