[Product-Developers] Plone string encoding problem

Steve McMahon steve at dcn.org
Thu Dec 22 18:01:10 UTC 2011


There's a good chance that your real problem is coming when you try to
write to MySQL. Somewhere in the process of doing that, you're trying to
pass an object type that's not understood by the interface (to MySQL), and
it's getting converted to a string representation.

On Thu, Dec 22, 2011 at 2:44 AM, mcelotti <m.celotti at tecnoteca.it> wrote:

> I have a Document (type_name=Document) containing this text:
> "accents è à ì ò ù"
>
> When I open the doc everything is fine and all the accents are correct.
>
> The problem comes with my custom script:
>
> items = context.portal_catalog(portal_type='Document',
> UID='a64ce6ceb295bcaa48ebff874379d907')
> array=[]
> for item in items:
>  dict={}
>  obj = item.getObject()
>  dict['text']= obj.getText()
>  array.append(dict)
> return array
>
> The output is:
> "accents \xc3\xa8 \xc3\xa0 \xc3\xac \xc3\xb2 \xc3\xb9"
>
> I need to write original content to database (mysql utf-8) but I'm stuck
> with this problem ...
>
> Also, if I modify my script this way (print output):
>
> items = context.portal_catalog(portal_type='Document',
> UID='a64ce6ceb295bcaa48ebff874379d907')
> array=[]
> for item in items:
>  dict={}
>  obj = item.getObject()
>  dict['text']= obj.getText()
>  print dict['text']
>  array.append(dict)
> return printed
>
> Everything is fine and I can see the correct text with accents.
>
> Thank you,
> Marco
>
> --
> View this message in context:
> http://plone.293351.n2.nabble.com/Plone-string-encoding-problem-tp7118197p7118197.html
> Sent from the Product Developers mailing list archive at Nabble.com.
> _______________________________________________
> Product-Developers mailing list
> Product-Developers at lists.plone.org
> https://lists.plone.org/mailman/listinfo/plone-product-developers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.plone.org/pipermail/plone-product-developers/attachments/20111222/70e1994e/attachment-0001.html>


More information about the Product-Developers mailing list