hi,
one of the modules in my programs stopped wroking after i upgraded from
python 2.3 to 2.4. I also changed my wxPython to unicode supported one
during the process.
what the module essentially does is search for a stirng pattern form a
list of strings.
this is the function:
def srchqu(self):
for i in range(1,len(qu)):#qu is the list of strings
if qu[i][0].lower().find(self.query)==-1:
pass
else:
#do some stuff here
I get this error message on calling the function:
Traceback (most recent call last):
File "E:\mdi\search.py", line 86, in OnSrchButton
self.srchqu()
File "E:\mdi\search.py", line 97, in srchqu
if qu[i][0].lower().find(self.query)==-1:
UnicodeDecodeError: 'ascii' codec can't decode byte 0x92 in position
66: ordinal not in range(128)
what is the problem and the solution? thanks in advance for any help.
Ashoka 5 5575
"ash" wrote: one of the modules in my programs stopped wroking after i upgraded from python 2.3 to 2.4. I also changed my wxPython to unicode supported one during the process. what the module essentially does is search for a stirng pattern form a list of strings. this is the function:
def srchqu(self): for i in range(1,len(qu)):#qu is the list of strings if qu[i][0].lower().find(self.query)==-1: pass else: #do some stuff here
I get this error message on calling the function:
Traceback (most recent call last): File "E:\mdi\search.py", line 86, in OnSrchButton self.srchqu() File "E:\mdi\search.py", line 97, in srchqu if qu[i][0].lower().find(self.query)==-1: UnicodeDecodeError: 'ascii' codec can't decode byte 0x92 in position 66: ordinal not in range(128)
what is the problem and the solution? thanks in advance for any help.
one of qu[i][0] or self.query is a unicode string, and the other is an 8-bit
string that contains something that's not ASCII.
to make the code do what you do, make sure to decode the 8-bit strings
into Unicode strings.
</F>
Thanks Fredrik, i decoded both qu[i][0] and self.query to latin_1
(self.query.decode("latin_1")) and i am not getting the error now.
If you dont mind, I have another question for you. I use wxPython for
GUI development. When i use a string containing "&" character as a
label for statictext, the "&" does'nt appear.It is replaced by a short
_. I have tried different encodings but have no success. what should i
do so that "&" appears on screen?
thanks once againg for your help.
regards,
Ashoka
"ash" wrote: If you dont mind, I have another question for you. I use wxPython for GUI development. When i use a string containing "&" character as a label for statictext, the "&" does'nt appear.It is replaced by a short _. I have tried different encodings but have no success. what should i do so that "&" appears on screen?
I don't use wxPython, but & is commonly used by GUI toolkits to place
an underscore under a menu choice, to indicate what hotkey to use
for that menu choice. e.g. "&Save" or "E&xit".
I don't know how to escape that in wxPython. it might be a good idea
to post your question on some wxpython mailing list: http://www.wxpython.org/maillist.php
</F>
ash napisał(a): If you dont mind, I have another question for you. I use wxPython for GUI development. When i use a string containing "&" character as a label for statictext, the "&" does'nt appear.It is replaced by a short _. I have tried different encodings but have no success. what should i do so that "&" appears on screen?
Double your ampersand character.
--
Jarek Zgoda http://jpa.berlios.de/
Thanks Jarek, doubling worked. I thought it was a problem with encoding
but didnt think of escaping it. thanks a lot.
Thanks for Fredrik too for taking the trouble.
Regards,
Ashoka This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Ruslan |
last post by:
Hi, everybody.
In this excerpt of code
enc = 'some_type_of_encoding'
def _encode(v):
if isinstance(v, UnicodeType):
v = v.encode(v)
return v
|
by: Robin Siebler |
last post by:
I have no idea what is causing this error, or how to fix it. The full error is:
Traceback (most recent call last):
File "D:\ScriptRuntime\PS\Automation\Handlers\SCMTestToolResourceToolsBAT.py",...
|
by: dbri.tcc |
last post by:
Hello
I am getting somewhat random UnicodeDecodeError messages in my program.
It is random in that I will be going through a pysqlite database of
records, manipulate
the results, and it will...
|
by: Robin Haswell |
last post by:
Okay I'm getting really frustrated with Python's Unicode handling, I'm
trying everything I can think of an I can't escape Unicode(En|De)codeError
no matter what I try.
Could someone explain to...
|
by: Karl |
last post by:
error msg:
Mod_python error: "PythonHandler mod_python.publisher"
Traceback (most recent call last):
File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line
299, in HandlerDispatch...
|
by: Oleg Parashchenko |
last post by:
Hello,
I'm working on an unicode-aware application. I like to use "print" to
debug programs, but in this case it was nightmare. The most popular
result of "print" was:
UnicodeDecodeError:...
|
by: Jorgen Bodde |
last post by:
Hi All,
I am relatively new to python unicode pains and I would like to have
some advice. I have this snippet of code:
def playFile(cmd, args):
argstr = list()
for arg in...
|
by: Jorgen Bodde |
last post by:
Hi Edwin,
Filemask is obvious as it is assigned in the python code itself. It is
"%file%". The idea is that the file clicked is substituted for the
"%file%" by the replace action. The file that...
|
by: Gilles Ganault |
last post by:
Hello
I'm getting this error while downloading and parsing web pages:
=====
title = m.group(1)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position
48: ordinal not in...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |