Método en PL SQL para entidades html

Este es un método para poder convertir facilmente todos los caracteres en entidades HTML

CREATE OR REPLACE FUNCTION ASCII2HTML(cadena VARCHAR2)RETURN VARCHAR2 IS
text VARCHAR2(4000);
BEGIN
text := cadena;
text := REPLACE(text,'À',CHR(38)||'Agrave;');
text := REPLACE(text,'Á',CHR(38)||'Aacute;');
text := REPLACE(text,'Â',CHR(38)||'Acirc;');
text := REPLACE(text,'Ã',CHR(38)||'Atilde;');
text := REPLACE(text,'Ä',CHR(38)||'Auml;');
text := REPLACE(text,'Å',CHR(38)||'Aring;');
text := REPLACE(text,'Æ',CHR(38)||'AElig;');
text := REPLACE(text,'Ç',CHR(38)||'Ccedil;');
text := REPLACE(text,'È',CHR(38)||'Egrave;');
text := REPLACE(text,'É',CHR(38)||'Eacute;');
text := REPLACE(text,'Ê',CHR(38)||'Ecirc;');
text := REPLACE(text,'Ë',CHR(38)||'Euml;');
text := REPLACE(text,'Ì',CHR(38)||'Igrave;');
text := REPLACE(text,'Í',CHR(38)||'Iacute;');
text := REPLACE(text,'Î',CHR(38)||'Icirc;');
text := REPLACE(text,'Ï',CHR(38)||'Iuml;');
text := REPLACE(text,'Ð',CHR(38)||'ETH;');
text := REPLACE(text,'Ñ',CHR(38)||'Ntilde;');
text := REPLACE(text,'Ò',CHR(38)||'Ograve;');
text := REPLACE(text,'Ó',CHR(38)||'Oacute;');
text := REPLACE(text,'Ô',CHR(38)||'Ocirc;');
text := REPLACE(text,'Õ',CHR(38)||'Otilde;');
text := REPLACE(text,'Ö',CHR(38)||'Ouml;');
text := REPLACE(text,'Ø',CHR(38)||'Oslash;');
text := REPLACE(text,'Ù',CHR(38)||'Ugrave;');
text := REPLACE(text,'Ú',CHR(38)||'Uacute;');
text := REPLACE(text,'Û',CHR(38)||'Ucirc;');
text := REPLACE(text,'Ü',CHR(38)||'Uuml;');
text := REPLACE(text,'Ý',CHR(38)||'Yacute;');
text := REPLACE(text,'Þ',CHR(38)||'THORN;');
text := REPLACE(text,'ß',CHR(38)||'szlig;');
text := REPLACE(text,'à',CHR(38)||'agrave;');
text := REPLACE(text,'á',CHR(38)||'aacute;');
text := REPLACE(text,'â',CHR(38)||'acirc;');
text := REPLACE(text,'ã',CHR(38)||'atilde;');
text := REPLACE(text,'ä',CHR(38)||'auml;');
text := REPLACE(text,'å',CHR(38)||'aring;');
text := REPLACE(text,'æ',CHR(38)||'aelig;');
text := REPLACE(text,'ç',CHR(38)||'ccedil;');
text := REPLACE(text,'è',CHR(38)||'egrave;');
text := REPLACE(text,'é',CHR(38)||'eacute;');
text := REPLACE(text,'ê',CHR(38)||'ecirc;');
text := REPLACE(text,'ë',CHR(38)||'euml;');
text := REPLACE(text,'ì',CHR(38)||'igrave;');
text := REPLACE(text,'í',CHR(38)||'iacute;');
text := REPLACE(text,'î',CHR(38)||'icirc;');
text := REPLACE(text,'ï',CHR(38)||'iuml;');
text := REPLACE(text,'ð',CHR(38)||'eth;');
text := REPLACE(text,'ñ',CHR(38)||'ntilde;');
text := REPLACE(text,'ò',CHR(38)||'ograve;');
text := REPLACE(text,'ó',CHR(38)||'oacute;');
text := REPLACE(text,'ô',CHR(38)||'ocirc;');
text := REPLACE(text,'õ',CHR(38)||'otilde;');
text := REPLACE(text,'ö',CHR(38)||'ouml;');
text := REPLACE(text,'ø',CHR(38)||'oslash;');
text := REPLACE(text,'ù',CHR(38)||'ugrave;');
text := REPLACE(text,'ú',CHR(38)||'uacute;');
text := REPLACE(text,'û',CHR(38)||'ucirc;');
text := REPLACE(text,'ü',CHR(38)||'uuml;');
text := REPLACE(text,'ý',CHR(38)||'yacute;');
text := REPLACE(text,'þ',CHR(38)||'thorn;');
text := REPLACE(text,'ÿ',CHR(38)||'yuml;');
return(text);
EXCEPTION
WHEN NO_DATA_FOUND THEN
return '';
END ;

1 comentarios:

cristian dijo...

Genial justo lo que buscaba, muchas gracias desde Santiago de Chile.

Publicar un comentario