Latest version display Chinese has proglem?

5 views
Skip to first unread message

Glen Tang

unread,
Oct 7, 2009, 10:19:45 PM10/7/09
to CNProg open discussion
First of all, 感谢CNProg做了这么出色的程序。 But I have some issues, i don't know
why when I was trying to post a chinese version question i got the
following errors. Is it related to my Python??

OperationalError at /questions/ask/

(1366, "Incorrect string value: '\\xE9\\x97\\xAE\\xE4\\xB8\\x80...'
for column 'title' at row 1")

Request Method: POST
Request URL: http://localhost:8000/questions/ask/
Exception Type: OperationalError
Exception Value:

(1366, "Incorrect string value: '\\xE9\\x97\\xAE\\xE4\\xB8\\x80...'
for column 'title' at row 1")

Exception Location: C:\Python25\lib\site-packages\MySQLdb
\connections.py in defaulterrorhandler, line 35
Python Executable: C:\Python25\python.exe
Python Version: 2.5.1

Chagel

unread,
Oct 8, 2009, 6:58:26 AM10/8/09
to CNProg open discussion
Glen,

Have you checked character set of your database/table/column?
Make sure you use right one with asian language support, e.g:

create database DB DEFAULT CHARACTER SET UTF8 COLLATE utf8_general_ci;

-Mike

Yun Tang

unread,
Oct 8, 2009, 9:23:21 AM10/8/09
to cha...@gmail.com, cnp...@googlegroups.com
Hello Mike,
I've resloved the database issue, you are right, i should set default
character to UTF8. But after that I have another issue. When I submit
a Chinese question. It seems URL related function can't convert
Chinese character into ACSII. I don't know what's settings should I
change in django.

Thanks,
Glen

2009/10/8 Chagel <cha...@gmail.com>:

Glen Tang

unread,
Oct 8, 2009, 9:47:23 PM10/8/09
to CNProg open discussion
When I submit a question with chinese title i got the following error
++++++++++++++++++++++++++++++++++++++++++++++++++++
UnicodeEncodeError at /questions/ask/

'ascii' codec can't encode characters in position 14-36: ordinal not
in range(128), HTTP response headers must be in US-ASCII format

Request Method: POST
Request URL: http://localhost:8000/questions/ask/
Exception Type: UnicodeEncodeError
Exception Value:

'ascii' codec can't encode characters in position 14-36: ordinal not
in range(128), HTTP response headers must be in US-ASCII format

Exception Location: C:\Python25\Lib\site-packages\django\http
\__init__.py in _convert_to_ascii, line 309
Python Executable: C:\Python25\python.exe
Python Version: 2.5.1
Python Path: ['E:\\Toupiao360\\PythonSoftware\\cnprog-CNPROG-ca1cf62\
\website', 'C:\\Python25\\lib\\site-packages\\setuptools-0.6c9-
py2.5.egg', 'C:\\Python25\\lib\\site-packages\
\django_debug_toolbar-0.8.1.alpha-py2.5.egg', 'C:\\Python25\\lib\\site-
packages\\django_authopenid-0.9.6-py2.5.egg', 'D:\\Program Files\
\ArcGIS\\bin', 'C:\\Windows\\system32\\python25.zip', 'C:\\Python25\
\DLLs', 'C:\\Python25\\lib', 'C:\\Python25\\lib\\plat-win', 'C:\
\Python25\\lib\\lib-tk', 'C:\\Python25', 'C:\\Python25\\lib\\site-
packages']
Server time: 星期四, 8 十月 2009 21:34:31 -0400

Call Stack:

Environment:

Request Method: POST
Request URL: http://localhost:8000/questions/ask/
Django Version: 1.1
Python Version: 2.5.1
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'django.contrib.humanize',
'forum',
'django_authopenid']
Installed Middleware:
('django.middleware.gzip.GZipMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.transaction.TransactionMiddleware')


Traceback:
File "C:\Python25\lib\site-packages\django\core\handlers\base.py" in
get_response
93. response = callback(request, *callback_args,
**callback_kwargs)
File "E:\Toupiao360\PythonSoftware\cnprog-CNPROG-ca1cf62\website\forum
\views.py" in ask
292. return HttpResponseRedirect
(question.get_absolute_url())
File "C:\Python25\Lib\site-packages\django\http\__init__.py" in
__init__
407. self['Location'] = redirect_to
File "C:\Python25\Lib\site-packages\django\http\__init__.py" in
__setitem__
320. header, value = self._convert_to_ascii(header, value)
File "C:\Python25\Lib\site-packages\django\http\__init__.py" in
_convert_to_ascii
309. value = value.encode('us-ascii')

Exception Type: UnicodeEncodeError at /questions/ask/
Exception Value: 'ascii' codec can't encode characters in position
14-36: ordinal not in range(128), HTTP response headers must be in US-
ASCII format

Chagel

unread,
Oct 12, 2009, 11:58:38 AM10/12/09
to CNProg open discussion
Hi,

Check if Sailing's latest changes(30f8b8) have resolved your problem.

-Mike

Yun Tang

unread,
Oct 12, 2009, 8:58:16 PM10/12/09
to cnp...@googlegroups.com
Great! After updating latest version. I can typing Chinese again!
Awesome job. Awesome app. Thanks Mic and Sailing.

2009/10/12 Chagel <cha...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages