Hugues JEAN-BAPTISTE wrote:
Hello,
When I begun with wxPython, I had the same problem and I have spent many time to understand.
But it's very simple ...
Now I use wxPython version without unicode and I add at the beginning of my program :#!/usr/bin/python
# -*- coding: cp1252 -*-And I can add comments with accents ...
Yours.
Hugues JEAN-BAPTISTE (hjb@agorinfo.fr)
AGORINFO
1330, route de Neufchatel
F-76230 QUINCAMPOIX
Tel. : 33.2.32.80.87.87 / Fax : 33.2.32.80.87.88
Web site : http://www.agorinfo.frAlessandro Crugnola *sephiroth* a écrit :
Hi,
First i used wxPython without unicode for my text editor but i need to switch to the unicode version in order to have unicode
support.
But now i need anyway the possibility to save files with just the ascii charset.
Also i'm a newbie..Before using wxPython unicode with wxSTC i had not problem save with the ascii codec word like "andrè", but now i am not able
anymore to save in ascii because the string which wxSTC give back is in unicode and the codec raise me an error trying to convert in
ascii...Is there a solution or the accented cha must be saved eveytime in utf8?
Firstly you need wxPython with unicode support and now you don't need. You are confusing me.
I maybe wrong but if I IRC, non-unicode wxPython defaults to latin-1. Since you are OK with cp1252 which is latin-1, non-unicode wxPython is OK. If you want to use unicode wxPython, you can write the file by writing it out to latin-1. But beware that any characters outside latin-1 will result in out of range error.
(latin1_encode, latin1_decoder, latin1_reader, latin1_writer) = codecs.lookup('latin-1')
file = latin1_writer(open(path_to_file, 'w'))
file.write(unicode_string_that_falls_within_cp1252)
Remember your users or application must not use characters other than those within cp1252.
Derrick