12 August 2008

XML/HTML SPECIAL/MULTI BYTE CHARACTERS PARSING

From Oracle 10g onwards you can use utl_i18n.escape_reference api to handle any special characters in XML/HTML parsing

Example
SELECT utl_i18n.escape_reference('Àà¡ÁáÂâÃãÄä¥ÅåÆæÇçÈèÉéÊêËëÌì­ÍíÎîÏïÐðÑñÒòÓóÔôµÕõÖöØøÙùÚúÛûÜüÝýÞþ¿ßÿ°ªº','US7ASCII') utl_fld
from dual;

Output:
Aa!AaAaÃãAaYÅåÆæCcEeEeEeEeIi-IiIiIiÐðÑñOoOoOoµÕõOoØøUuUuUuUuYyÞþ¿ßy°ªº

Till Oracle 9 use Convert and replace fuctions to change the double byte characters to single byte characters.


SELECT replace(convert('Àà¡ÁáÂâÃãÄä¥ÅåÆæÇçÈèÉéÊêËëÌì­ÍíÎîÏïÐðÑñÒòÓóÔôµÕõÖöØøÙùÚúÛûÜüÝýÞþ¿ßÿ°ªº','US7ASCII') ,'?') utl_fld from dual;

Output

Aa!AaAaAaYCcEeEeEeEeIi-IiIiIiOoOoOoOoUuUuUuUuYyy

No comments: