hi everyone,
I went throught a tricky encoding problem with the maskededit component:
I have a string with some iso-8859-1 encoding (value , type 'str') which i apply the method SetValue(str) , and i raise this error :
File "/home/kevin/cvs/pylaf/pylaf/client/wx/form/ctrl.py", line 141, in setValue
self._ctrl.SetValue(str(value).decode('iso-8859-15'))
File "/home/francois/tmp/pkg/usr/lib/python2.3/site-packages/wx/lib/masked/textctrl.py", line 200, in SetValue
File "/usr/lib/python2.3/site-packages/wx/lib/masked/maskededit.py", line 5568, in _Paste
valid_paste, replacement_text, replace_to = self._validatePaste(paste_text, sel_start, sel_to, raise_on_invalid)
File "/usr/lib/python2.3/site-packages/wx/lib/masked/maskededit.py", line 5424, in _validatePaste
if not self._isTemplateChar(replace_to) and self._isCharAllowed( char, replace_to, allowAutoSelect=False, ignoreInsertRight=True):
File "/usr/lib/python2.3/site-packages/wx/lib/masked/maskededit.py", line 4385, in _isCharAllowed
approved = char in okChars
UnicodeDecodeError: 'ascii' codec can't decode byte 0xaa in position 52: ordinal not in range(128)
I've tried lots of things, and the only working solution i came with, is patching the maskededit.py (line 4385):
* former version of maskededit.py :
> approved = char in okChars
* Patched version :
>if type(char) is types.UnicodeType:
> char = char.encode("iso-8859-1")
>approved = char in okChars
My working version of wx is : 2.5.2.7
As I am not a wx expert, is a patch the right solution (never the less, not mine as i butaly hard-code the encoding), or do i miss something??
regards,
Kevin Thackray