Hello,

I was directed to send the following query to this email address.

I am using Python 2.5.1 (r251:54863, Dec 16 2010, 14:12:43) on mac OS 1.5.

How does one set up the character manipulation in python to avoid mangling foreign-language characters (i.e., French accents, German umlauts, etc.)?

For example, I have a text file example.txt. The unix command cat displays the contents as the single line:

São Paulo

However, if I read this file in a python script and then write it back out character by character using the python script

#!/usr/bin/python
input=open("example.txt","r")
output=open("out.txt","w")
for line in input:
  for i in range (len (line)):
     output.write ("%s\n" % line[i])

then the characters in the file are given as

S
?
?
o

P
a
u
l
o

Why does python does not make use of the character codes that are used by the Mac OS? Is there a way to tell python to recognize the OS character set?

Many thanks, -- Joe

Joseph Grcar
6059 Castlebrook Drive
Castro Valley, CA 94552 USA

email jfgr...@comcast.net
phone 1-510-581-1353

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG

Reply via email to