utf-8 fails

22 views
Skip to first unread message

Brötchen Pinguin

unread,
Oct 5, 2013, 6:15:06 PM10/5/13
to creole...@googlegroups.com
Hiho,

somehow creoleparser doesn't work with utf-8 codes. I tried it out with the Ü umlaut.

Run this

# -*- coding: utf-8 -*-
import creoleparser
print creoleparser.text2html ("Ü")

It fails with

Traceback (most recent call last):
  File "utf8.py", line 3, in <module>
    print creoleparser.text2html ("Ü")
  File "/usr/lib/python2.7/dist-packages/creoleparser/core.py", line 127, in __call__
    return self.render(text, **kwargs)
  File "/usr/lib/python2.7/dist-packages/creoleparser/core.py", line 120, in render
    return stream.render(**kwargs)
  File "/usr/lib/python2.7/dist-packages/genshi/core.py", line 183, in render
    return encode(generator, method=method, encoding=encoding, out=out)
  File "/usr/lib/python2.7/dist-packages/genshi/output.py", line 57, in encode
    return _encode(''.join(list(iterator)))
  File "/usr/lib/python2.7/dist-packages/genshi/output.py", line 508, in __call__
    yield _emit(kind, data, escape(data, quotes=False))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: ordinal not in range(128)

regards
Daniel

Jim Garrison

unread,
Oct 5, 2013, 9:11:05 PM10/5/13
to creole...@googlegroups.com
On 10/05/2013 03:15 PM, Br�tchen Pinguin wrote:
> somehow creoleparser doesn't work with utf-8 codes. I tried it out with
> the � umlaut.
>
> Run this
>
> # -*- coding: utf-8 -*-
> import creoleparser
> print creoleparser.text2html ("�")

You're passing it as a bytestring when it should really be a unicode string.

>>> import creoleparser
>>> print creoleparser.text2html(u"�")
<p>�</p>
Reply all
Reply to author
Forward
0 new messages