2 ms·
At a guess, there's nothing in Python stdlib which understands graphemes vs code points - you can palindrome the code points but that's not necessarily a palind
by zimpenfish 1y ago
At a guess, there's nothing in Python stdlib which understands graphemes vs code points - you can palindrome the code points but that's not necessarily a palindrome of what you "see" in the string.
(Same goes for Go, it turns out, as I discovered this morning.)
- chuckadams 1y agoIt's a scream how easy it is in PHP of all things: function is_palindrome(string $str): bool { return $str === implode('', array_reverse(grapheme_str_split($str))); } $palindrome = 'satanoscillatemymetallicsonatas'; $polar_bear = "\u{1f43b}\u{200d}\u{2744}\u{fe0f}"; $palindrome = str_replace($palindrome, 'y', $polar_bear); is_palindrome($palindrome);