Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Write Unicode str as utf-8

Reply
Thread Tools

Write Unicode str as utf-8

 
 
kent sin
Guest
Posts: n/a
 
      02-15-2005
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
 
Reply With Quote
 
 
 
 
Erik Max Francis
Guest
Posts: n/a
 
      02-15-2005
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
if len(str(a)) == len(str(r)) and isMult(a, r): faster if isMult isslow? maestro Python 1 08-11-2008 01:17 PM
str.equals(null) or str==null ? Stefan Ram Java 21 08-03-2006 06:43 PM
It is fun.the result of str.lower(str()) Sullivan WxPyQtKinter Python 5 03-09-2006 08:09 AM
sizeof(str) or sizeof(str) - 1 ? Trevor C Programming 9 04-10-2004 05:07 PM
what's the deference between str=null and str=" " ???????? David Java 2 08-03-2003 04:10 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57