Write Unicode str as utf-8

K

kent sin

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
 
E

Erik Max Francis

kent said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top