-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: utf8Len, utf8Codepoints, utf8Valid
closes #39
- Loading branch information
Showing
4 changed files
with
105 additions
and
7 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import "std"; | ||
|
||
test "utf8" { | ||
str msg = "hello 🔥 buzz !"; | ||
|
||
assert(msg.utf8Len() == 14, message: "Could get length of utf8 string"); | ||
assert(msg.utf8Valid(), message: "Could validate utf8 string"); | ||
|
||
str invalid = "hello \232 world!"; | ||
|
||
assert(!invalid.utf8Valid(), message: "Could not validate invalid utf8 string"); | ||
|
||
[str] codepoints = "I'm 🦇-man so 🔥 !".utf8Codepoints(); | ||
assert(codepoints[4] == "🦇", message: "Could get utf8 string codepoints"); | ||
} |