Ignore:
Timestamp:
18 Mar 2011, 17:52:21 (14 years ago)
Author:
uli
Message:

Fix ReST2HTML() to always deliver unicode strings. Otherwise we could
get EnodingErrors? when using this function with HTML forms.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/utils/helpers.py

    r5848 r5876  
    241241    Returns a tuple ``(<HTML_CODE>, <WARNINGS>)``, both being
    242242    strings. Where ``<HTML_CODE>`` is the HTML code generated from the
    243     source string, ``<WARNINGS>`` is a string containing any warning
    244     messages or ``None``.
     243    source string (in unicode), ``<WARNINGS>`` is a string containing
     244    any warning messages or ``None``.
    245245   
    246246    Regular multi-line ReStructuredText strings will be returned as
     
    322322    if warning_msgs == '':
    323323        warning_msgs = None
    324     return getInnerHTMLPart(fulldoc).strip(), warning_msgs
     324    result = getInnerHTMLPart(fulldoc).strip()
     325    if not isinstance(result, unicode):
     326        result = result.decode('utf-8')
     327    return result, warning_msgs
    325328
    326329def ReST2HTML(source_string):
     
    331334    warnings.
    332335
     336    The returned string will be unicode.
     337   
    333338    A regular document will be rendered like this:
    334339
Note: See TracChangeset for help on using the changeset viewer.