[KoCo-CVS] [Commit] cjkcodecs/tools genmap_korean.py genmap_ko_codecs.py
Brought to you by:
perky
From: Hye-Shik C. <pe...@us...> - 2003-05-14 06:46:52
|
perky 03/05/13 23:46:50 Added: tools genmap_korean.py Removed: tools genmap_ko_codecs.py Log: Go! KoCo! Revision Changes Path 1.1 cjkcodecs/tools/genmap_korean.py Index: genmap_korean.py =================================================================== # # genmap_korean.py: Korean Codecs Map Generator # # Copyright (C) 2003 Hye-Shik Chang <pe...@Fr...>. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # # $Id: genmap_korean.py,v 1.1 2003/05/14 06:46:50 perky Exp $ # from genmap_support import * KSX1001_C1 = (0x21, 0x7e) KSX1001_C2 = (0x21, 0x7e) UHCL1_C1 = (0x81, 0xa0) UHCL1_C2 = (0x41, 0xfe) UHCL2_C1 = (0xa1, 0xfe) UHCL2_C2 = (0x41, 0xa0) try: mapfile = open('CP949.TXT') except IOError: print "=>> Please download mapping table from http://www.unicode." \ "org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP949.TXT" raise SystemExit print "Loading Mapping File..." datever, decmap = loadmap(mapfile) uhcdecmap, ksx1001decmap = {}, {} for c1, c2map in decmap.iteritems(): for c2 in c2map.iterkeys(): if c1 >= 0xa1 and c2 >= 0xa1: ksx1001decmap.setdefault(c1&0x7f, {}) ksx1001decmap[c1&0x7f][c2&0x7f] = c2map[c2] else: # uhc uhcdecmap.setdefault(c1, {}) uhcdecmap[c1][c2] = c2map[c2] omap = open('map_ksx1001.h', 'w') printcopyright(omap) print "Generating KS X 1001 decode map..." genmap_decode(omap, "ksx1001", KSX1001_C1, KSX1001_C2, ksx1001decmap) print "Generating KS X 1001 decode map index..." print_decmapindex(omap, "ksx1001", ksx1001decmap, rng=(0, 127)) omap = open('map_cp949.h', 'w') printcopyright(omap) print "Generating UHC Level 1 decode map..." genmap_decode(omap, "uhc", UHCL1_C1, UHCL1_C2, uhcdecmap) print "Generating UHC Level 2 decode map..." genmap_decode(omap, "uhc", UHCL2_C1, UHCL2_C2, uhcdecmap) print "Generating UHC decode map index..." print_decmapindex(omap, "uhc", uhcdecmap) print "\nDone!" # ex: ts=8 sts=4 et |