Skip to content

Commit

Permalink
Fix issue with
Browse files Browse the repository at this point in the history
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)

when rendering template within non-ASCII strings (non-unicodes)
  • Loading branch information
vintozver committed Oct 3, 2012
1 parent 21a2010 commit 17af9b5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions jinja2/_markupsafe/_native.py
Expand Up @@ -40,6 +40,8 @@ def soft_unicode(s):
"""Make a string unicode if it isn't already. That way a markup
string is not converted back to unicode.
"""
if isinstance(s, str):
s = s.decode('utf-8')
if not isinstance(s, unicode):
s = unicode(s)
return s

0 comments on commit 17af9b5

Please sign in to comment.