codec to parse raw UCS data?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Oleg Leschov

    codec to parse raw UCS data?



    Where can I find a list and documentation for codecs?
    What I want to do is to make a unicode string out of unicode data.
    for example. I am parsing NTFS metadata, that contains filenames as
    UCS-2 code, so I have a binary string that pretends to be a UCS-2.
    Currently I am using hand-written module, a wrapper to iconv library, to make
    translation of this data (that is, I used it for that task).
    However, I am aware of python's codecs that are supposed to do the same
    thing in much prettier way.. So, as long as I can do things like
    st = u'\uxxxx' and such, I could construct and exec it, but this is ugly...
    Shouldn't there be a simple thing like <bin.string>.de code("UCS-2")
    that would return a python's unicode string?
    Or perhaps I've missed something in the documentation.. .


  • Fredrik Lundh

    #2
    Re: codec to parse raw UCS data?

    Oleg Leschov wrote:
    [color=blue]
    > Where can I find a list and documentation for codecs?
    > What I want to do is to make a unicode string out of unicode data.
    > for example. I am parsing NTFS metadata, that contains filenames as
    > UCS-2 code, so I have a binary string that pretends to be a UCS-2.[/color]

    the "utf-16-le" codec is probably what you want.

    (utf-16 is basically ucs-2 plus mechanisms to encode characters outside
    the 16-bit BMP set; IIRC, Windows 2k and later uses utf-16, not ucs-2).

    </F>




    Comment

    Working...