[ python-Bugs-1382096 ] MacRoman Encoding Bug (OHM vs. OMEGA)

SourceForge.net noreply at sourceforge.net
Fri Dec 16 15:47:10 CET 2005


Bugs item #1382096, was opened at 2005-12-16 03:22
Message generated for change (Comment added) made by lemburg
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1382096&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Unicode
Group: Python 2.4
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Sean B. Palmer (seanbpalmer)
Assigned to: M.-A. Lemburg (lemburg)
Summary: MacRoman Encoding Bug (OHM vs. OMEGA)

Initial Comment:
The file encodings/mac_roman.py in Python 2.4.1
contains the following incorrect character definition
on line 96: 

        0x00bd: 0x2126, # OHM SIGN

This should read: 

        0x00bd: 0x03A9, # GREEK CAPITAL LETTER OMEGA

Presumably this bug occurred due to a misreading, given
that OHM and OMEGA having the same glyph. Evidence that
the OMEGA interpretation is correct: 

0xBD   0x03A9   # GREEK CAPITAL LETTER OMEGA
-http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/ROMAN.TXT

Further evidence can be found by Googling for MacRoman
tables. This bug means that, for example, the following
code gives a UnicodeEncodeError when it shouldn't do: 

>>> u'\u03a9'.encode('macroman')

For a workaround, I've been using the following code: 

>>> import codecs
>>> from encodings import mac_roman
>>> mac_roman.decoding_map[0xBD] = 0x03A9
>>> mac_roman.encoding_map =
codecs.make_encoding_map(mac_roman.decoding_map)

And then, to use the example above: 

>>> u'\u03a9'.encode('macroman')
'\xbd'
>>> 

Thanks,

-- 
Sean B. Palmer


----------------------------------------------------------------------

>Comment By: M.-A. Lemburg (lemburg)
Date: 2005-12-16 15:47

Message:
Logged In: YES 
user_id=38388

This has been fixed in CVS and Python 2.5 will include the fix. 

A backport is not possible, because we've changed the way
charmap codecs work in 2.5.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1382096&group_id=5470


More information about the Python-bugs-list mailing list