File: idempotent_nfc_check.py

package info (click to toggle)
python-precis-i18n 1.1.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,836 kB
  • sloc: python: 1,825; sh: 28; makefile: 3
file content (21 lines) | stat: -rw-r--r-- 395 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Hunt for examples where order of NFC/Casefold makes a difference.

import unicodedata


def case(ch):
    return ch.casefold()


def nfc(ch):
    return unicodedata.normalize("NFC", ch)


def make(ch):
    return "%s%s" % (ch, unicodedata.normalize("NFD", ch))


for i in range(0, 0x010FFFF):
    s = make(chr(i))
    if case(nfc(s)) != nfc(case(s)):
        print(s.encode("unicode-escape"))