How to unpack data to unicode string?

Just van Rossum just at letterror.com
Mon Jun 4 10:29:50 EDT 2001


Fredrik Lundh wrote:
> 
> Martin Bless wrote:
> 
> > I'm doing a bit of analyzing TrueType files. (BTW, there's some good
> > information at www.microsoft.com/typography). There can be chunks of
> > unicode data inside truetype files which I can extract via slicing:
> >
> >   rawText = data[start:end]
> >
> > Now, how do I do the transformation of rawText
> > '\x00N\x00o\x00r\x00m\x00a\x00l'  ->  u'Normal' ?
> 
> try this:
> 
>     u = unicode(s, "utf-16-be")
> 
> also take a look at TTX/TTLib:
> 
>     http://www.letterror.com/code/ttx/index.html

Which is actually mondo out of date. However, a fresh source archive 
can be found here:

   http://www.petr.nl/just/FontTools.tar.gz

It doesn't yet use Python's Unicode facilities for the 'name' table:
it's still completely compatible with 1.5.x.

Just



More information about the Python-list mailing list