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 9216517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:26:04+00:00 2026-06-18T02:26:04+00:00

I know that this topic has been addressed by many, but for some reason

  • 0

I know that this topic has been addressed by many, but for some reason I cannot get UTF-8 encoding to work on my GAE app. I am retrieving a German string from an online form and then try to store it in a Stringproperty. The code looks as follows:

import from google.appengine.ext import db
import webapp2

class Item(db.Model):
  value = db.Stringproperty()

class ItemAdd(webapp2.RequestHandler):
    def post(self):
       item - Item()
       value = str(self.request.get(u'value'))
       item.value = value.encode('utf-8')
       item.put()

The error I get from this is:

File "C:\xxx", line 276, in post
value = str(self.request.get('value'))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 12: ordinal not in range(128)

Does anybody see what I am doing wrong?

UPDATE

The string I am retrieving is following: “Dit is een länge”
If I change the property type to TextProperty everything works, however I need to be able to filter on it so this doesn’t solve the problem.

  • 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-06-18T02:26:05+00:00Added an answer on June 18, 2026 at 2:26 am

    Webapp2 takes care of utf-8. In your post webapp2 gives you an utf-8 multidict. So you do not have to do it yourself. With a debugger you can find the multidict in the self.request

    class ItemAdd(webapp2.RequestHandler):
    
        def post(self):
           Item(value = self.request.POST('value')).put()
    

    To use utf-8 read this sblog post and never use : str() !!!! Your str() makes binary out of unicode
    http://blog.notdot.net/2010/07/Getting-unicode-right-in-Python

    And with python27 you can start your code with :

    #!/usr/bin/python
    # -*- coding: utf-8 -*-
    from __future__ import unicode_literals
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

ok, I know that this topic has been addressed several times on here, but
Ok so I know this topic has many questions, but I still haven't been
I know that this topic has been asked several times before but none of
I know that this topic has been beaten to death, but it seems that
I know that there have been many similar questions on this topic but none
I know that this topic has been already beaten enough, but I still don't
I know that this sort of question has been asked here before, but still
I know that this has already been asked here but the answer (using a
I know this topic has been discussed to death, but there is one thing
I know this topic has been discussed and killed over and over again, but

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.