HTML entities when URL posting to Twitter
I have created some links on a site I am working on for sharing to various
social networks via URL.
A number of these links include foreign characters in some of the
parameters. In order to construct the urls properly, I am using the
following: s.encode('ascii', 'xmlcharrefreplace'). This works
uneventfully; neither python nor jinja2 chokes on the strings. However,
when I test the share links, the entity replacements for the special
characters end up in the output. So, for instance, Lasse Hallström in the
url's Twitter status parameter shows up as Lasse Hallström in the
Twitter textbox shown by Twitter to the user.
What's the proper way for handling this? Is it ok to replace those
characters with characters that don't require entities in a URL? Is there
any python code posted anywhere for doing this?
I haven't shown any code because I don't think this is a coding error.
Pretty sure I am constructing the urls properly. The issue is URL posting
characters of this kind to Twitter etc.
No comments:
Post a Comment