Created
September 17, 2022 16:44
-
-
Save gdamore/13cc3b50aa3dbffca291f76b87849645 to your computer and use it in GitHub Desktop.
unicode grapheme test
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
import std; | |
import std.utf; | |
import std.uni; | |
import std.range.primitives : walkLength; | |
import std.range : take, drop; | |
void main() | |
{ | |
auto s2 = "\U0001f9db\u200d\u2640"; // this is a female vampire (vampire + ZWJ + female) | |
auto wr = byGrapheme(s2); | |
writefln("s2 is %s\n", s2); | |
writefln("graphemes %d (expect 1)\n", wr.walkLength); // this should be "1" | |
s2 = "\U0001f1fa\U0001f1f8"; // flag modified with USA, displays as US flag | |
wr = byGrapheme(s2); | |
writefln("s2 is %s\n", s2); | |
writefln("graphemes %d (expect 1)\n", wr.walkLength); // this should be "1" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment