Python UTF-8 and codecs

Serge Orlov serge.orlov at gmail.com
Wed Jun 28 00:11:38 CEST 2006


On 6/27/06, Mike Currie <dev at null.com> wrote:
> Okay,
>
> Here is a sample of what I'm doing:
>
>
> Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on
> win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> filterMap = {}
> >>> for i in range(0,255):
> ...     filterMap[chr(i)] = chr(i)
> ...
> >>> filterMap[chr(9)] = chr(136)
> >>> filterMap[chr(10)] = chr(133)
> >>> filterMap[chr(136)] = chr(9)
> >>> filterMap[chr(133)] = chr(10)

This part is incorrect, it should be:

filterMap = {}
for i in range(0,128):
    filterMap[chr(i)] = chr(i)

filterMap[chr(9)] = unichr(136)
filterMap[chr(10)] = unichr(133)
filterMap[unichr(136)] = chr(9)
filterMap[unichr(133)] = chr(10)



More information about the Python-list mailing list