Create Unicode object problem

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

    Create Unicode object problem

    Hi!

    Is there any way I can create a unicode object from the unicode code
    itself.
    I extract the code from a file and need to create a unicode object
    that represents the corresponding character.

    So what i get from reading my file is a string containing for example
    the code 'u8c79' (Chinese character).

    Help on this would be appreciated!

    Kathy
  • Irmen de Jong

    #2
    Re: Create Unicode object problem

    Kathy wrote:[color=blue]
    > Is there any way I can create a unicode object from the unicode code
    > itself.
    > I extract the code from a file and need to create a unicode object
    > that represents the corresponding character.
    >
    > So what i get from reading my file is a string containing for example
    > the code 'u8c79' (Chinese character).[/color]
    [color=blue][color=green][color=darkred]
    >>> unichr(eval('u8 c79'.replace('u ','0x')))[/color][/color][/color]
    u'\u8c79'


    --irmen

    Comment

    Working...