467,080 Members | 939 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,080 developers. It's quick & easy.

[Help]UnicodeDecodeError

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
result = object(req)

File "/usr/lib/python2.3/site-packages/mod_python/publisher.py",
line 136, in handler
result = util.apply_fs_data(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('utf_8')

UnicodeDecodeError: '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
  • viewed: 2118
Share:
1 Reply
Karl wrote:
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
result = object(req)

File "/usr/lib/python2.3/site-packages/mod_python/publisher.py",
line 136, in handler
result = util.apply_fs_data(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('utf_8')

UnicodeDecodeError: '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 UnicodeDecodeError. Other possible values are 'ignore' and 'replace'
as well as any other name registerd with codecs.register_error that is
able to handle UnicodeDecodeErrors.

Peter

Mar 18 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by ash | last post: by
2 posts views Thread by dbri.tcc@gmail.com | last post: by
24 posts views Thread by ChaosKCW | last post: by
4 posts views Thread by Robin Haswell | last post: by
3 posts views Thread by A_H | last post: by
reply views Thread by Jorgen Bodde | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.