Re: convert to html within MySQL
Posted by: Alexander Barkov
Date: December 01, 2006 05:28AM

It should be possible using a number of recursive REPLACE() calls.
For example, this query replaces two letters:

SELECT REPLACE(REPLACE('Mélanie', 'é', 'é'), 'á', '&aacute');

However, a query replacing all iso-8859-1 entities will look cumbersome.
You can create a stored function and hide these replaced inside the function:

CREATE FUNCTION HTMLEncode(x varchar(255)) returns varchar(255)
RETURN REPLACE(REPLACE(x, 'é', 'é'), 'á', '&aacute');


The queries will look short and elegant after that:

SELECT HTMLEncode(c1) FROM t1;

Options: ReplyQuote


Subject
Views
Written By
Posted
6905
November 20, 2006 01:27PM
Re: convert to html within MySQL
3395
December 01, 2006 05:28AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.