Note that there are some explanatory texts on larger screens.

plurals
  1. POUnicodeDecodeError from a GET-parameter in webapp2
    text
    copied!<p>I'm getting a UnicodeDecodeError when recieving a GET-parameter from webapp2 that contains unicode characters, and then using it to do a NDB query. I get the same error message when manually running a unicode() on the parameter in the handler, so there either seems to be a problem in webapp2's URL routing or I've missed something. Preferably, all GET-parameters should be converted to unicode before getting passed into the handler so I don't need to do manual conversions in all of my handlers. I actually think it's worked before in an earlier version.</p> <p>The full error message read: <code>UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)</code></p> <p>The GET-parameter contains the following string: <code>göteborg</code>. It looks fine when I raise an Exception on it, but gives me an error when I (or NDB) use unicode() on it.</p> <p><strong>EDIT:</strong></p> <p>In NDB, it fails on the following code: <code>File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\datastore_types.py", line 1562, in PackString pbvalue.set_stringvalue(unicode(value).encode('utf-8'))</code></p> <p><strong>EDIT 2:</strong></p> <p>I later found out that my problem was actually not with GET-parameters, but the routed parts of the URL that the handler's get() method recieve as keyword arguments. Check out <a href="https://stackoverflow.com/questions/13114151/how-do-i-make-handlers-automatically-decodeutf-8-on-all-routed-parameters/">this follow-up question</a> for solutions how to decode these parameters automatically.</p> <p>Thanks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload