I am using wxPython 2.9 where ansi/pure ascii is no longer an option. I am running OSX 10.10.5 Yosemite. I have python 2.7.
I don’t remember upgrading wxPython since this problem started. It is possible the upgrade to Yosemite caused it.
I will try and put together a minimum working example that causes the issue.
···
On Thu, Nov 19, 2015 at 3:25 PM, Chris Barker chris.barker@noaa.gov wrote:
–
You received this message because you are subscribed to the Google Groups “wxPython-users” group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On Thu, Nov 19, 2015 at 6:43 AM, Ryan Krauss ryanlists@gmail.com wrote:
When I read the text I call .encode() on the string that gets returned.
you really never want to call a bare encode() – if you want something encoded, you should darn well know what you want it encoded to!
Since sys.getdefaultencoding() returns ‘ascii’, python tries to encode the string from the textctrl as ascii by default. This throws an error.
To work around this, I had to call .encode(‘UTF-8’).
why are you encoding it anyway? If you are passing it off to something that really, really requires ASCII, then UTF-8 is going to break it anyway – even though the encode call won’t fail. But if, for instance the unicode string has a LEFT DOUBLE QUOTATION MARK character, then that will get encoded as multibyte in utf-8, and that may make something downstream barf. You really don’t want to push this can down the road.
So you should probably encode to ascii, but with “replace” or something so it won’t barf: “ignore”
or “replace”.
But the bigger issue in my mind is that if my application specifically required ascii text, the textctrl doesn’t seem capable of this.
it used to be possible to get an ascii build of wx – but that may not be an option anymore.
If I type " into the box, it gets converted to a curly UTF-8 equivalent
just to be a bit pedantic here – it’s not a UTF-8 anyting – it’s apparently a unicode LEFT DOUBLE QUOTATION MARK character – which is actualy really really , weird – I seriously doubt that wx has anything to do with it – the native control must be replacing it – but THAT has got to be something you can turn off – you _might_want that in a fancy-dancy word processor ,-- but you sure as heck wouldn’t’ want it in programmers text editor.
what platform/version, etc are you seeing this on ?
and what widget?
-CHB
and there doesn’t seem to be a way to get back to pure ascii. I write a lot of code to communicate over serial between python and Arduino where we need to use pure ascii. The ability to get pure ascii from a textctrl seems to be lost in wxPython 2.9.
Ryan
–
You received this message because you are subscribed to the Google Groups “wxPython-users” group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov
–
On Thu, Nov 19, 2015 at 8:21 AM, Boštjan Mejak bostjan.xperia@gmail.com wrote:
What’s wrong with UTF-8?
On Thu, Nov 19, 2015, 14:26 Ryan Krauss ryanlists@gmail.com wrote:
I have an application where a textctrl is converting to unicode against my will and this is causing issues later in my code. If I type a quotation mark " in the textctrl, I can watch it be converted to the the curved unicode version. How do I stop this from happening? I tried adding
wx.SetDefaultPyEncoding(‘ascii’)
to the code, but it doesn’t seem to have changed anything. I would be glad to set a global setting somewhere or even just a parameter or style for the control. I just need this to go away.
Thanks,
Ryan
–
You received this message because you are subscribed to the Google Groups “wxPython-users” group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
–
You received this message because you are subscribed to the Google Groups “wxPython-users” group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.