News for hackers. Stuff that matters.
Re:String length functions for single emoji characters evalu... by patrickas on Friday March 26, 2021 @11:25AM (#26593227)
Raku seems to be more correct (DWIM) in this regard than all the examples given in the post...

  my \emoji = "\c[FACE PALM]\c[EMOJI MODIFIER FITZPATRICK TYPE-3]\c[ZERO WIDTH JOINER]\c[MALE SIGN]\c[VARIATION SELECTOR-16]";

  #one character
  say emoji.chars; # 1 
  #Five code points
  say emoji.codes; # 5

  #If I want to know how many bytes that takes up in various encodings...
  say emoji.encode('UTF8').bytes; # 17 bytes 
  say emoji.encode('UTF16').bytes; # 14 bytes 

Edit: Updated to use the names of each code point since HN cannot display the emoji
Re:String length functions for single emoji characters evalu... by cjm42 on Friday March 26, 2021 @03:37PM (#26596045)
And if you try to say emoji.length, you'll get an error:

No such method 'length' for invocant of type 'Str'. Did you mean any of these: 'codes', 'chars'?

Because as the article points out, the "length" of a string is an ambiguous concept these days.

Re:String length functions for single emoji characters evalu... by duskwuff on Friday March 26, 2021 @12:39PM (#26594121)
You can represent it as a sequence of escapes. If Raku handles this the same way as Perl5, it should be:

    $a = "\N{FACE PALM}\N{EMOJI MODIFIER FITZPATRICK TYPE-3}\N{ZERO WIDTH JOINER}\N{MALE SIGN}\N{VARIATION SELECTOR-16}";
Re:String length functions for single emoji characters evalu... by csharptwdec19 on Friday March 26, 2021 @01:45PM (#26594884)
now do it in YAML