Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7690793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:28:40+00:00 2026-05-31T20:28:40+00:00

I have a unicode string that was encoded on the client side using JS

  • 0

I have a unicode string that was encoded on the client side using JS encodeURIComponent.

If I use the following in Python locally, I get the expected result:

>>> urllib.unquote("Foo%E2%84%A2%20Bar").decode("utf-8")
>>> u'Foo\u2122 Bar'

But when I run this in Google App Engine, I get:

Traceback (most recent call last):
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/_webapp25.py", line 703, in __call__
    handler.post(*groups)
  File "/base/data/home/apps/s~kaon-log/2.357769827131038147/main.py", line 143, in post
    path_uni = urllib.unquote(h.path).decode('utf-8')
  File "/base/python_runtime/python_dist/lib/python2.5/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 3-5: ordinal not in range(128)

I’m still using Python 2.5, in case that makes a difference. What am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T20:28:41+00:00Added an answer on May 31, 2026 at 8:28 pm

    My guess is that h.path is a unicode object. Then urllib.unquote would return a unicode object. When decode is called on a unicode object at first it is converted to str using default encoding (which is ascii) and here you get the 'ascii' codec can't encode exception.

    Here is a proof:

    >>> urllib.unquote(u"Foo%E2%84%A2%20Bar").decode("utf-8")
    ...
    UnicodeEncodeError: 'ascii' codec can't encode characters in position 3-5: ordinal not in range(128)
    

    This should work:

    urllib.unquote(h.path.encode('utf-8')).decode("utf-8")
    

    There is a stackoverflow thread which explains why unicode doesn’t work with urllib.unquote: How to unquote a urlencoded unicode string in python?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question, which Unicode encoding to use while encoding .NET string into
I have some unicode text that I want to clean up using regular expressions.
I have a Unicode string encoded, say, as UTF8 . One string in Unicode
Usually, the best practice in python, when using international languages, is to use unicode
I have a object which contains unicode data and I want to use that
I want to send email messages that have arbitrary unicode bodies in a Python
I have a string that represents an HTML block. All the unicode characters are
I have a string that is HTML encoded: '''<img class="size-medium wp-image-113"\ style="margin-left: 15px;" title="su1"\
Following this thread solution, I have managed to get a bunch of lists that
For example, if I have a unicode string, I can encode it as an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.