Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.)



It'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);




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: