3

Plone is showing the special chars from my mother language (Brazilian Portuguese) in its pages. However, when I use a spt page I created it shows escape sequences, e.g.:

Educa\xc3\xa7\xc3\xa3o

instead of

Educação

(by the way, it means Education). I'm creating a python function to replace the escape sequences with the utf chars, but I have a feeling that I'm slaving away without need.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
HelioAraujo
  • 227
  • 1
  • 10
  • You're going to need to tell us how you're inserting the string if we're going to be able to help. Meanwhile, http://plone.org/documentation/manual/developer-manual/internationalization-i18n-and-localization-l10n may help. – SteveM Dec 26 '11 at 15:55

2 Answers2

5

Are you interpolating catalog search results? Those are, by necessity (the catalog cannot handle unicode) UTF-8 encoded.

Just use the .decode method on strings to turn them into unicode again:

value = value.decode('utf8')
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
1

A better way should be to use safe_unicode function https://github.com/plone/Products.CMFPlone/blob/master/Products/CMFPlone/utils.py#L458

from Products.CMFPlone.utils import safe_unicode
value = safe_unicode(value)
rodfersou
  • 914
  • 6
  • 10