[Pythonmac-SIG] ANN: TECManager 0.2 - Codec bridge between Python unicode and proprietary Apple character sets

Bob Ippolito bob at redivi.com
Mon Sep 29 21:15:11 EDT 2003


As per Jack's suggestion, I've revised TECManager to become a full 
bridge between Python's encodings and Apple's Text Encoding Conversion 
Manager.  On my US version of OS X, the following codecs are available 
immediately after importing the TECManager package:
mac_systemscript
mac_simpchinese
mac_thai
mac_roman
mac_gurmukhi
mac_arabic
mac_devanagari
mac_currentscript
mac_hebrew
mac_centraleuroroman
mac_tradchinese
mac_japanese
mac_tibetan
mac_korean
mac_gujarati
mac_cyrillic
mac_greek

The Mac specific encodings that come with Python are:
mac_cyrillic
mac_greek
mac_iceland
mac_latin2
mac_roman
mac_turkish

Notice that some of the Python codecs are not taken over by TECManager. 
  This is because TECManager only generates "built-in" codecs based upon 
the name of system scripts, and does not have any specific default 
encodings for region or language codes.  However, it is possible to 
create codecs for any language code you want.  For example, to create 
the turkish encoding, one would do the following:

 >>> import TECManager as TM
 >>> TM.tec_codecs.createModule('encodings.mac_turkish', 
TM.getTextEncoding(script=TM.smRoman, language=TM.langTurkish, 
region=TM.verTurkey))

which will (assuming you haven't used mac_turkish already and caused 
encodings to cache it) replace the built-in support for mac_turkish.

 From there, you can simply 'encodedstring'.decode('mac_turkish') or 
u'unicodestring'.encode('mac_turkish')

Note that this is still experimental software and I'm looking for users 
so I can nail the bugs out of it.  Currently, the only issue I know of 
is that when using the encoding error functions some input may not get 
converted (I'm only trapping errors relating to missing mappings, other 
inconsistencies are getting passed up as exceptions at the moment).

The only build requirement is Pyrex, and I've made some small changes 
that allow TECManager to compile with a vanilla Pyrex (my hack is no 
longer necessary).

homepage:
	http://undefined.org/python/

pydoc documentation:
	http://undefined.org/python/TECManager-0.2-pydoc.html

source tarball:
	http://undefined.org/python/TECManager-0.2.tar.gz

PackageManager URL (Python 2.3 - 10.2.x):
	http://undefined.org/python/pimp/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 2515 bytes
Desc: not available
Url : http://mail.python.org/pipermail/pythonmac-sig/attachments/20030929/1db17aa7/attachment.bin


More information about the Pythonmac-SIG mailing list