[Quickie] Django - Forcing the encoding of strings


1 Estrelas2 Estrelas3 Estrelas4 Estrelas5 Estrelas (1 votes, average: 3.00 out of 5)
Loading ... Loading ...

I had problems with accented strings coming from a webservice. Everything was working perfectly!! minus the accents in words ...

I searched for a long time in oracle and could not make it work. I had a word with @ kplaube and he gave me this tip.

To force the encoding of a string in Django use:

  1. , strings_only= False , errors= 'replace' ) force_unicode (s, encoding = 'utf-8', strings_only = False, errors = 'replace')

Done it all worked chubby!

Ref: # Useful http://docs.djangoproject.com/en/dev/ref/unicode/-utility-functions
Credits: @ kplaube

  1. 4 Comments to "[Quickie] Django - Forcing the encoding of strings"

  2. Hey doctor, dropped the PHP time?
    're Already hooked on the python, or even turning back?

    Sincerely,

    Reply Reply

    By diego (15 comments) on 07/01/2010

  3. I left nothing heehhe

    I love PHP yet, but as I'm having a nice touch with Python / Django I'll post some stuff related :)

    A big hug!

    Reply Reply

    By Marcelo Sabadini (101 comments) on 08/01/2010

  4. Oops, this tip is good. Do not know :)

    Thanks Marcelo ;)

    Reply Reply

    By Francis Souza (3 comments) on 23/01/2010

  5. That broke a galhão heheheheh

    Reply Reply

    By Marcelo Sabadini (101 comments) on 28/01/2010

Place a comment

Links in comments should be nofollow free .

Get Adobe Flash player Plugin by wpburn.com wordpress themes