#!/usr/bin/env python3

# Use the proper idiom in the main module ...
# NOTE: See https://docs.python.org/3.13/library/multiprocessing.html#the-spawn-and-forkserver-start-methods
if __name__ == "__main__":
    # Import standard modules ...
    import unicodedata

    # Define an example string as raw bytes (to avoid ambiguity) and then
    # convert it to a Unicode string ...
    null_byt = b'Where is \xe2\x80\xa6 Reykjav\xc3\xadk?'
    null_str = null_byt.decode("utf-8")

    # Print summary ...
    print(f"example string as a Unicode string: {null_str}")
    print(f"example string as a bytes sequence: {repr(null_byt)}")

    # Loop over possible Unicode normalizations ...
    for form in ["NFC", "NFKC", "NFD", "NFKD",]:
        # Convert the example Unicode string to the current Unicode
        # normalization and then convert it to raw bytes (to avoid ambiguity) ...
        test_str = unicodedata.normalize(form, null_str)
        test_byt = test_str.encode("utf-8")

        # Print summary ...
        print(f"{form:4s}    {repr(unicodedata.is_normalized(form, null_str)):5s}    {repr(test_byt)}")
