473,796 Members | 2,482 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[Help]UnicodeDecodeEr ror

error msg:
Mod_python error: "PythonHand ler mod_python.publ isher"

Traceback (most recent call last):

File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line
299, in HandlerDispatch
result = object(req)

File "/usr/lib/python2.3/site-packages/mod_python/publisher.py",
line 136, in handler
result = util.apply_fs_d ata(object, req.form, req=req)

File "/usr/lib/python2.3/site-packages/mod_python/util.py", line
361, in apply_fs_data
return object(**args)

File "/var/www/html/sky.py", line 38, in main
sresult = sresult.decode( 'zh-hk').encode('ut f_8')

UnicodeDecodeEr ror: 'big5hkscs' codec can't decode bytes in position
958-959: illegal multibyte sequence
Wt can I do, since there is some characters, is there any solutions to
solve it???

thx

Mar 18 '07 #1
1 2391
Karl wrote:
error msg:
Mod_python error: "PythonHand ler mod_python.publ isher"

Traceback (most recent call last):

File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line
299, in HandlerDispatch
result = object(req)

File "/usr/lib/python2.3/site-packages/mod_python/publisher.py",
line 136, in handler
result = util.apply_fs_d ata(object, req.form, req=req)

File "/usr/lib/python2.3/site-packages/mod_python/util.py", line
361, in apply_fs_data
return object(**args)

File "/var/www/html/sky.py", line 38, in main
sresult = sresult.decode( 'zh-hk').encode('ut f_8')

UnicodeDecodeEr ror: 'big5hkscs' codec can't decode bytes in position
958-959: illegal multibyte sequence
Wt can I do, since there is some characters, is there any solutions to
solve it???
Other than requiring valid input?
You can choose a more lenient decoding strategy, e. g.:

sresult = sresult.decode( 'zh-hk', "replace")
>>help(s.decode )
Help on built-in function decode:

decode(...)
S.decode([encoding[,errors]]) -object

Decodes S using the codec registered for encoding. encoding defaults
to the default encoding. errors may be given to set a different error
handling scheme. Default is 'strict' meaning that encoding errors raise
a UnicodeDecodeEr ror. Other possible values are 'ignore' and 'replace'
as well as any other name registerd with codecs.register _error that is
able to handle UnicodeDecodeEr rors.

Peter

Mar 18 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
5617
by: ash | last post by:
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
2
1583
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 throw UnicodeDecodeError apparently without regard as to what data is being used.
24
9073
by: ChaosKCW | last post by:
Hi I am reading from an oracle database using cx_Oracle. I am writing to a SQLite database using apsw. The oracle database is returning utf-8 characters for euopean item names, ie special charcaters from an ASCII perspective. I get the following error: > SQLiteCur.execute(sql, row)
4
3515
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 me what I'm doing wrong here, so I can hope to throw light on the myriad of similar problems I'm having? Thanks :-) Python 2.4.1 (#2, May 6 2005, 11:22:24) on linux2 Type "help", "copyright", "credits" or "license" for more information.
11
4771
by: prats | last post by:
I want to write a GUI application in PYTHON using QT. This application is supposed to take in Japanese characters. I am using PyQt as the wrapper for using QT from python. I am able to take input in japanese. But I am unable to display them back to GUI. It displays some junk characters Can anyone suggest me some way how to debug the issue. The code used for tranferring data from view to document is: " codec =...
4
5382
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: 'ascii' codec can't decode byte 0xXX in position 0: ordinal not in range(128) I spent two hours fixing it, and I hope it's done. The solution is one
1
1915
by: Ben | last post by:
Is the following a known bug? $ python -U Python 2.4.4 (#1, Oct 23 2006, 13:58:18) on linux2 Type "help", "copyright", "credits" or "license" for more information. Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/lib64/python2.4/random.py", line 834, in ? _inst = Random()
3
4748
by: A_H | last post by:
Help! I've scraped a PDF file for text and all the minus signs come back as u'\xad'. Is there any easy way I can change them all to plain old ASCII '-' ??? str.replace complained about a missing codec.
0
1735
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 needs to be substituted is a simple file on disk. Here is a dump of the file and it's characters. I do understand that it is not in the range of ASCII but how can I make it so that it will work?
0
9525
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10221
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10169
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10003
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9050
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7546
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5569
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.