display VARCHAR(mysql) and special chars in html
Radovan Garabik
garabik at kassiopeia.juls.savba.sk
Tue Feb 22 03:13:06 EST 2005
Jonas Meurer <jonas at freesources.org> wrote:
> hello,
>
> my script selects a comment saved as VARCHAR in MySQL and displays it
> inside an html page.
>
> the problem is, that the comment contains several special characters, as
> mysterious utf-8 hyphens, german umlauts, etc.
>
> i could write a function to parse the comment and substitute special
> chars with the relevant html code, but maybe this already exists in some
> module?
just make the page in utf-8, and you'll save you a lot of troubles
>
> if not, it'll be hard work, as i've to consider many special chars, and
> at least iso-8859-1* and utf-8 as charmaps.
if you insist...
a = u'\u010c'
a.encode('ascii', 'xmlcharrefreplace')
--
-----------------------------------------------------------
| Radovan Garabík http://melkor.dnp.fmph.uniba.sk/~garabik/ |
| __..--^^^--..__ garabik @ kassiopeia.juls.savba.sk |
-----------------------------------------------------------
Antivirus alert: file .signature infected by signature virus.
Hi! I'm a signature virus! Copy me into your signature file to help me spread!
More information about the Python-list
mailing list