• Portretfoto van Maarten Kling
    Maarten Kling


When using ‘web_intelligent_plain_text_to_html’ from portal_transforms, make sure your input is decoded to utf-8 and the output is unicode.

Creating the option for users to create text in a textarea and save that on a object will always encounter encoding problems you did not test. Users will use charaters like é or ö in some kind of sentences. When displaying this message using web_intelligent_plain_text_to_html, to auto convert url’s or newlines you have to make sure you can handel them all.

Here we will have a tal snippet to display contect.getMessage:

<span tal:content="structure python:
  The message

This way getMessage may return éëê like characters and will still convert all urls to clickable url’s. web_intelligent_plain_text_to_html works pretty nice by default, and will convert all links to email or urls to clickable links and convert newlines to html br tags.

Nothing worse than getting:

UnicodeDecodeError: 'ascii' codec can't decode
byte 0xc3 in position 284: ordinal not in range(128)
We love code


Wij maken gebruik van cookies. Meer hierover lees je in onze Privacy- cookieverklaring.