what's the correct way to handle unicode? - trying to print out graphemes here.
    ag0aep6g 
    anonymous at example.com
       
    Tue Jul  3 14:37:42 UTC 2018
    
    
  
On Tuesday, 3 July 2018 at 13:32:52 UTC, aliak wrote:
> foreach (c; "👩👩👦👦🏳️🌈") {
>   writeln(c);
> }
>
> So basically the above just doesn't work. Prints gibberish.
Because you're printing one UTF-8 code unit (`char`) per line.
> So I figured, std.uni.byGrapheme would help, since that's what 
> they are, but I can't get it to print them back out? Is there a 
> way?
>
> foreach (c; "👩👩👦👦🏳️🌈".byGrapheme) {
>   writeln(c.<????>);
> }
You're looking for `c[]`. But that won't work, because std.uni 
apparently doesn't recognize those as grapheme clusters. The 
emojis may be too new. std.uni is based on Unicode version 6.2, 
which is a couple years old.
    
    
More information about the Digitalmars-d-learn
mailing list