开发者

String crashing when passing through urlize

When I try to pass the content of a TextField that contains characters like í ó ú ñ etc开发者_如何学Go it crashes. I tried doing string.encode('utf-8') and putting # encoding: utf-8 in top of the views file and the file that has the urlize filter. Any idea what I can do?


According to the Django documentation, urlize converts URLs in text into clickable links. According to RFC1728, URLs can contains only "graphic printable characters of the US-ASCII coded character set."

The characters you mentioned are not part of the required ASCII subset, so urlize can be expected to fail. You will need to escape your input to remove such characters. UTF-8 is valid for the contents of an HTML document, but not for a URL.

Your UTF-8 content can be converted to ASCII using the snippet found here: http://djangosnippets.org/snippets/588/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜