coming from Archetypes contents, the generated field getters used to return strings, so that e.g. the value
u'Ramón' will be returned as
'Ram\xc3\x83\xc2\xb3n', which is an UTF-8 encoded unicode string.
in Dexterity, the value would be returned like this
u'Ram\xc3\xb3n', which is just the unicode string.
Here again at a glance:
>>> name_at = obj.getName() >>> name_at 'Ram\xc3\x83\xc2\xb3n' >>> name_dx = obj.name >>> name_dx u'Ram\xc3\xb3n' >>> name_at.decode('utf-8') u'Ram\xc3\xb3n >>> name_dx.encode('utf-8') 'Ram\xc3\x83\xc2\xb3n'
What is the correct (or better) way to do in Plone?
We are still at Python 2.7 and unicode encode/decode errors are haunting me already since a long time and my brain will probably never fully understand it.
But when it comes to Python 3.x, is there something to take special note regarding this topic?