File: create_valid_hanzi.py

package info (click to toggle)
libpyzy 1.0.1-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,544 kB
  • sloc: python: 23,416; cpp: 20,929; makefile: 346; sql: 94; php: 16; sh: 16
file content (17 lines) | stat: -rw-r--r-- 404 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

def get_validate_hanzi():
    validate_hanzi = file("valid_utf16.txt").read().decode("utf16")
    return set(validate_hanzi)

def main():
    hanzi = get_validate_hanzi()
    hanzi = list(hanzi)
    hanzi.sort()
    print "# -*- coding: utf-8 -*- "
    print "valid_hanzi = set(["
    for c in hanzi:
        print "    u\"%s\"," % c.encode("utf8")
    print "])"

if __name__ == "__main__":
    main()