Created
February 2, 2020 22:59
-
-
Save davidfowl/e6b1bea56d7e5eec016c5072681ddee2 to your computer and use it in GitHub Desktop.
Works for surrogate pairs
This file contains hidden or 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