Write Unicode str as utf-8

Discussion in 'Python' started by kent sin, Feb 15, 2005.

  1. kent sin

    kent sin Guest

    Python support unicode, but some library don't. Write
    is one of them.

    When writing a csv file, The rows contains numbers and
    unicode str. It is a little pain to first convert all
    unicode str to utf-8 before writing the row.

    Are there anyway I can patch python such that It will
    convert the unicode string to utf-8 before the write?
    Where should I start?


    Best rgs,

    Kent Sin
     
    kent sin, Feb 15, 2005
    #1
    1. Advertising

  2. kent sin wrote:

    > Python support unicode, but some library don't. Write
    > is one of them.
    >
    > When writing a csv file, The rows contains numbers and
    > unicode str. It is a little pain to first convert all
    > unicode str to utf-8 before writing the row.


    Why?

    S = U.encode('utf-8')

    > Are there anyway I can patch python such that It will
    > convert the unicode string to utf-8 before the write?
    > Where should I start?


    codecs.open

    --
    Erik Max Francis && && http://www.alcyone.com/max/
    San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
    Describe a circle, stroke its back and it turns vicious.
    -- Ionesco
     
    Erik Max Francis, Feb 15, 2005
    #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. David
    Replies:
    2
    Views:
    505
    Thomas G. Marshall
    Aug 3, 2003
  2. Trevor

    sizeof(str) or sizeof(str) - 1 ?

    Trevor, Apr 3, 2004, in forum: C Programming
    Replies:
    9
    Views:
    664
    CBFalconer
    Apr 10, 2004
  3. Sullivan WxPyQtKinter

    It is fun.the result of str.lower(str())

    Sullivan WxPyQtKinter, Mar 7, 2006, in forum: Python
    Replies:
    5
    Views:
    356
    Tim Roberts
    Mar 9, 2006
  4. Stefan Ram

    str.equals(null) or str==null ?

    Stefan Ram, Jul 31, 2006, in forum: Java
    Replies:
    21
    Views:
    14,850
    Oliver Wong
    Aug 3, 2006
  5. Grzegorz ¦liwiñski
    Replies:
    2
    Views:
    1,031
    Grzegorz ¦liwiñski
    Jan 19, 2011
Loading...

Share This Page