Re: string u'hyv\xe4' to file as 'hyvä'

2010-12-27 Thread MRAB
On 27/12/2010 05:56, gintare wrote: Hello, STILL do not work. WHAT to be done. import codecs item=u'hyv\xe4' F=codecs.open('/opt/finnish.txt', 'w+', 'utf8') F.writelines(item.encode('utf8')) > F.close() As I said in my previous post, you shouldn't be using .writelines, and you shouldn't encode

Re: string u'hyv\xe4' to file as 'hyvä'

2010-12-27 Thread Alex Willmer
On Dec 27, 6:47 am, "Mark Tolonen" wrote: > "gintare" wrote in message > > In file i find 'hyv\xe4' instead of hyv . > > When you open a file with codecs.open(), it expects Unicode strings to be > written to the file.  Don't encode them again.  Also, .writelines() expects > a list of strings.  Us

Re: string u'hyv\xe4' to file as 'hyvä'

2010-12-26 Thread Mark Tolonen
"gintare" wrote in message news:83dc3076-9ddc-42bd-8c33-6af96b263...@l32g2000yqc.googlegroups.com... Hello, STILL do not work. WHAT to be done. import codecs item=u'hyv\xe4' F=codecs.open('/opt/finnish.txt', 'w+', 'utf8') F.writelines(item.encode('utf8')) F.close() In file i find 'hyv\xe4' i

Re: string u'hyv\xe4' to file as 'hyvä'

2010-12-26 Thread gintare
Hello, STILL do not work. WHAT to be done. import codecs item=u'hyv\xe4' F=codecs.open('/opt/finnish.txt', 'w+', 'utf8') F.writelines(item.encode('utf8')) F.close() In file i find 'hyv\xe4' instead of hyvä. (Sorry for mistyping in previous letter about 'latin-1'. I was making all possible combin

Re: string u'hyv\xe4' to file as 'hyvä'

2010-12-26 Thread MRAB
On 26/12/2010 22:43, gintare wrote: Could you please help me with special characters saving to file. I need to write the string u'hyv\xe4' to file. I would like to open file and to have line 'hyvä' import codecs word= u'hyv\xe4' F=codecs.open(/opt/finnish.txt, 'w+','Latin-1') This opens the f