python unicode display of chinese characters

Discussion in 'Python' started by Posadas, Dennis, Dec 9, 2003.

  1. Hi,

    I've done some google searching w/c referred me to a couple of
    articles on unicode, but I'm looking for something really simple - not
    for a web application.

    See my sample code below. Any ideas how to convert it to display
    maybe Simplified Chinese ?

    Rgds,
    Dennis

    ====================================================
    #ucode.py

    #get unicode number
    ucode_num = str(raw_input('Enter the string : '))

    #define constants
    encode_type = 'utf-8'
    display_type = 'cp-347' #for IBM consoles

    #define unicode
    character_display = unicode(ucode_num, encode_type)


    #print character to be displayed
    print character_display.encode(display_type)
     
    Posadas, Dennis, Dec 9, 2003
    #1
    1. Advertising

  2. Posadas, Dennis

    Serge Orlov Guest

    > "Posadas, Dennis" <> wrote in message news:<>...
    > Hi,
    >
    > I've done some google searching w/c referred me to a couple of
    > articles on unicode, but I'm looking for something really simple - not
    > for a web application.
    >
    > See my sample code below. Any ideas how to convert it to display
    > maybe Simplified Chinese ?


    The first idea is to debug input and output separately, i.e. save
    your Chinese text to utf-8 file in a Chinese-aware editor. Read
    it from your Python program and try to display.
    You're trying to use cp347 encoding, did you install it? My
    python installation does not have it.
    What console do you use? Are you sure it supports cp347?

    -- Serge.
     
    Serge Orlov, Dec 10, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    7
    Views:
    6,689
    Joerg Jooss
    Feb 25, 2005
  2. omegaman
    Replies:
    1
    Views:
    595
    omegaman
    Sep 21, 2004
  3. Replies:
    2
    Views:
    418
  4. Grzegorz ¦liwiñski
    Replies:
    2
    Views:
    1,027
    Grzegorz ¦liwiñski
    Jan 19, 2011
  5. Elie Grouchko
    Replies:
    1
    Views:
    177
Loading...

Share This Page