#!/usr/bin/env python3
"""Unicode-aware palindrome checker.

No external dependencies; stdlib only (unicodedata).
"""

import unicodedata


def is_palindrome(s: str) -> bool:
    """Return True if *s* is a palindrome, False otherwise.

    - Handles full Unicode (not just ASCII): uses Unicode normalization
      (NFKD) so compatibility characters (full-width forms, ligatures,
      composed/decomposed variants) are folded to a canonical form.
    - Ignores case (uses casefold, which handles more than lower()).
    - Ignores all non-alphanumeric characters.
    """
    # Normalize: decompose compatibility characters so that, e.g.,
    # full-width 'Ａ' and ASCII 'A' compare equal after filtering.
    normalized = unicodedata.normalize("NFKD", s)
    # Keep only letters and digits (works for CJK, accented Latin, etc.).
    filtered = "".join(ch for ch in normalized if ch.isalnum())
    # Ignore case.
    folded = filtered.casefold()
    return folded == folded[::-1]


if __name__ == "__main__":
    tests = [
        ("", True),                                   # empty string
        ("racecar", True),                            # plain ASCII palindrome
        ("A man, a plan, a canal: Panama", True),     # punctuation/spaces ignored
        ("Was it a car or a cat I saw?", True),       # case + punctuation ignored
        ("上海自来水来自海上", True),                  # Chinese (CJK) palindrome
    ]

    all_passed = True
    for text, expected in tests:
        result = is_palindrome(text)
        status = "PASS" if result == expected else "FAIL"
        if result != expected:
            all_passed = False
        print(f"{status}: is_palindrome({text!r}) -> {result} (expected {expected})")

    print("-" * 60)
    print("ALL TESTS PASSED" if all_passed else "SOME TESTS FAILED")
