[KoCo-CVS] [Commit] cjkcodecs/tools genmap_support.py
Brought to you by:
perky
From: Hye-Shik C. <pe...@us...> - 2003-06-02 11:21:09
|
perky 03/06/02 04:21:06 Modified: tools genmap_support.py Log: Enable load sbcs mappings. Revision Changes Path 1.6 +6 -8 cjkcodecs/tools/genmap_support.py Index: genmap_support.py =================================================================== RCS file: /cvsroot/koco/cjkcodecs/tools/genmap_support.py,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- genmap_support.py 17 May 2003 21:17:39 -0000 1.5 +++ genmap_support.py 2 Jun 2003 11:21:06 -0000 1.6 @@ -26,14 +26,14 @@ # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # -# $Id: genmap_support.py,v 1.5 2003/05/17 21:17:39 perky Exp $ +# $Id: genmap_support.py,v 1.6 2003/06/02 11:21:06 perky Exp $ # import re COPYRIGHT_HEADER = """\ /* - * $Id: genmap_support.py,v 1.5 2003/05/17 21:17:39 perky Exp $ + * $Id: genmap_support.py,v 1.6 2003/06/02 11:21:06 perky Exp $ */ """ re_UNIMAPDATE = re.compile('Date:\s*([ a-zA-Z0-9/]*)') @@ -142,15 +142,13 @@ print >> fo, "};" print >> fo -def loadmap(fo, sethighbit=0, natcol=0, unicol=1): +def loadmap(fo, natcol=0, unicol=1, sbcs=0): fo.seek(0, 0) head = fo.read(1024) mapdatever = '%s-%s' % ( re_UNIMAPVERSION.findall(head)[0], re_UNIMAPDATE.findall(head)[0] ) - if sethighbit: - sethighbit = 0x80 fo.seek(0, 0) decmap = {} @@ -160,9 +158,9 @@ row = map(eval, line.split()) loc, uni = row[natcol], row[unicol] - if loc >= 0x100: - decmap.setdefault((loc >> 8) | sethighbit, {}) - decmap[(loc >> 8)|sethighbit][(loc & 0xff)|sethighbit] = uni + if loc >= 0x100 or sbcs: + decmap.setdefault((loc >> 8), {}) + decmap[(loc >> 8)][(loc & 0xff)] = uni return mapdatever, decmap |