imnotEnvy
11/14/2017 - 2:40 AM

Unicode String Safe Compare

Unicode String Safe Compare

from unicodedata import normalize

def nfc_equal(str1, str2):
    return normalize('NFC', str1) == normalize('NFC', str2)

def fold_equal(str1, str2):
    return (normalize('NFC', str1).casefold() == 
            normalize('NFC', str2).casefold())