Character set conversion between mac and pc

Martin von Loewis loewis at informatik.hu-berlin.de
Sun Oct 1 15:53:02 EDT 2000


=?ISO-8859-1?Q?Fran=E7ois_Pinard?= <pinard at iro.umontreal.ca> writes:

> I would surely like to have an option generating them for Python, but I
> wonder what the most useful format would be.  

If input and output are 8-bit character sets, wouldn't a string usable
for string.translate indeed be the best option?

Manually massaging (if you want to leave a massage, speak after the
bleep) your macintosh_IBM850 table, I'd get

macintosh_IBM850=					\
'\0\1\2\3\4\5\6\7'					\
'\010\011\012\013\014\015\016\017'			\
'\020\021\022\023\024\025\026\027'			\
'\030\031\032\033\034\035\036\037'			\
' !"#$%&\'()*+,-./'					\
'0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_'	\
'`abcdefghijklmnopqrstuvwxyz{|}~\177'			\
'\216\217\200\220\245\231\232\240'			\
'\205\203\204\306\206\207\202\212'			\
'\210\211\241\215\214\213\244\242'			\
'\225\223\224\344\243\227\226\201'			\
'\264\370\275\234\365\304\364\341'			\
'\251\270\302\357\371\301\222\235'			\
'\260\361\262\263\276\346\345\313'			\
'\300\271\272\246\247\310\221\233'			\
'\250\255\252\303\237\305\354\256'			\
'\257\311\377\267\307\315\316\333'			\
'\320\321\347\350\362\236\366\273'			\
'\230\331\332\317\334\335\355\337'			\
'\314\372\253\261\277\266\322\265'			\
'\323\324\326\327\330\336\340\342'			\
'\360\343\351\352\353\325\363\374'			\
'\356\254\274\373\367\375\376\312'

Provided I made no mistakes when producing this string - wouldn't that
work for string.translate out of the box?

> Suggestions most welcome!

For Python 2.0, I'd like to see it generate conversion modules
following the 'encodings' package. That, of course, would require that
they convert from and to Unicode.

Regards,
Martin



More information about the Python-list mailing list