Re: the stupid encoding problem to stdout



Sérgio Monteiro Basto <sergiomb@xxxxxxx> writes:

Ben Finney wrote:

In this case your shell has no preference for the encoding (since
you're redirecting output to a file).

How I say to python that I want that write in utf-8 to files ?

You already did:

In the first print statement you specify the encoding UTF-8, which
is capable of encoding the characters.

If you want UTF-8 on the byte stream for a file, specify it when opening
the file, or when reading or writing the file.

--
\ “But Marge, what if we chose the wrong religion? Each week we |
`\ just make God madder and madder.” —Homer, _The Simpsons_ |
_o__) |
Ben Finney
.



Relevant Pages

  • Re: How do I display unicode value stored in a string variable using ord()
    ... But they are not ascii pages, they are MOSTLY ascii. ... They are already in utf-8 on disk though that doesn't matter since ... decade to when unicode was added to Python. ... Python 2 was to clean up past mistakes and compromises, ...
    (comp.lang.python)
  • Re: Unicode formatting for Strings
    ... I write u"" to specify my unicode string ... I save it in the UTF-8 format ... Python is choking on the Byte Order Mark that Notepad puts at the ... No BOM, no problem. ...
    (comp.lang.python)
  • Using codecs.EncodedFile() with Python 2.5
    ... I used this function successfully with Python 2.4 to alter the encoding ... of a set of database records from latin-1 to utf-8, ... astring = fx.readline ... newchars, decodedbytes = self.decode ...
    (comp.lang.python)
  • Re: Replace and inserting strings within .txt files with the use of regex
    ... I created a folder names 'test' in me 'd:\' ... at one point in this thread you switched from Python 2.x to Python 3..2. ... and I recommend that you stick to one while you are still in newbie mode. ... When i open index.php within Notapad++ it says its in utf-8 without ...
    (comp.lang.python)
  • UTF-8
    ... First off: i thoroughly enjoy python. ... I use it for scientific computing with scipy, numpy and matplotlib and it's an amazingly efficient and elegant language. ... The default encoding i wish to set is UTF-8 since it encodes unicode and is nowadays the standard encoding. ...
    (comp.lang.python)