Created
March 10, 2022 22:14
-
-
Save si618/c03f253941f1d1673f6bdfdbcd2f4abd to your computer and use it in GitHub Desktop.
REPL friendly version of Dylan Beattie's normalization gist
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
// Refactored from https://gist.github.com/dylanbeattie/336b6b8990f0db6dd00d238ad114092a | |
using System.Text; | |
NormalizationForm[] forms = new[] { | |
NormalizationForm.FormC, NormalizationForm.FormD, | |
NormalizationForm.FormKC, NormalizationForm.FormKD | |
}; | |
void Compare(string s1, string s2) | |
{ | |
Console.WriteLine($"s1 == s2: {s1 == s2}"); | |
foreach (var form in forms) | |
{ | |
var result = s1.Normalize(form) == s2.Normalize(form); | |
Console.WriteLine($"{form}: {result}"); | |
} | |
} | |
Console.OutputEncoding = Encoding.UTF8; | |
var s1 = "Ⓗⓔⓛⓛⓞ"; | |
var s2 = "Hello"; | |
Compare(s1, s2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment