-
-
Save dalexsoto/413e102973462f7d4f0a02942e0d7d92 to your computer and use it in GitHub Desktop.
Works for surrogate pairs
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
static bool IsPalin(string s) | |
{ | |
var bi = s.Length - 1; | |
foreach (var r in s.EnumerateRunes()) | |
{ | |
if (!Rune.TryGetRuneAt(s, bi - (r.Utf16SequenceLength - 1), out var b) || !r.Equals(b)) | |
{ | |
return false; | |
} | |
bi -= r.Utf16SequenceLength; | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment