encoding

When using unicode strings in output it is usually necessary to explicitly use the string encode method as output is (by default) ISO-8859-1.

For instance:

   1 x = u"MyString and \uAADF"
   2 f = open("/tmp/filename")
   3 f.write(x.encode("UTF-8"))
   4 f.close()

External Sites

BradsWiki: Programming Notes/PythonUnicode (last edited 2006-05-22 02:25:57 by BradleyDean)