Skip to content

Instantly share code, notes, and snippets.

@ufcpp
Created November 10, 2020 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ufcpp/f119b4c3584a2b57089a63502ee6958d to your computer and use it in GitHub Desktop.
Save ufcpp/f119b4c3584a2b57089a63502ee6958d to your computer and use it in GitHub Desktop.
.NET 5.0 で GetTextElementEnumerator がまともになったらしい
using System;
using System.Globalization;
// net5.0 で実行するとちゃんと4要素列挙される。
// (netcoreapp3.1 だと Emoji ZWJ Sequence に対応してなくて数十個に分かれる。)
var s = "👩🏻‍👦🏼👨🏽‍👦🏾‍👦🏿👩🏼‍👨🏽‍👦🏼‍👧🏽👩🏻‍👩🏿‍👧🏼‍👧🏾";
var e = StringInfo.GetTextElementEnumerator(s);
while (e.MoveNext())
{
Console.WriteLine(e.Current);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment