Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix non-ascii character encoding problem #3

Merged
merged 1 commit into from
Sep 25, 2014
Merged

fix non-ascii character encoding problem #3

merged 1 commit into from
Sep 25, 2014

Conversation

quiver
Copy link

@quiver quiver commented Mar 31, 2012

tornado.web.RequestHandler.get_argument returns a unicode string.
http://www.tornadoweb.org/documentation/web.html?#tornado.web.RequestHandler.get_argument

And urllib.urlencode converts unicode chars into string chars before percent-encoding them.
If an argument contains non-ascii characters, encoding(default charset is system dependent) results in UnicodeEncodeError.

Example query:
http://HOST:8000/?q=%E3%83%88%E3%83%AB%E3%83%8D%E3%83%BC%E3%83%89

- tornado.web.RequestHandler.get_argument returns a unicode string.
  And urllib.urlencode converts unicode chars into string chars
  before percent-encoding them.
  If an argument contains non-ascii characters, encoding(default
  charset is system dependent) results in UnicodeEncodeError.
@quiver
Copy link
Author

quiver commented Mar 31, 2012

My experience with Tornado is less than a day(that's why I bought your book!),
so there may be a better solution.

brendanberg added a commit that referenced this pull request Sep 25, 2014
fix non-ascii character encoding problem
@brendanberg brendanberg merged commit a8a9414 into Introduction-to-Tornado:master Sep 25, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants