如何逃避<>和&字符到Oracle PL / SQL中的html实体 [英] How to escape <, >, and & characters to html entities in Oracle PL/SQL
问题描述
我需要直接从oracle PL / SQL包发送HTML电子邮件。这个工作几乎很好。
I need to send HTML emails directly from oracle PL/SQL package. This works almost fine.
我有一个问题,从表中提取的一些数据包含的东西,如< S>
,< L>
,以及有时被视为HTML标签的类似片段,即使不是,它们总是被忽略,从不显示。
I have problem with the fact that some of the data fetched from a table contain things like <S>
, <L>
, and similar fragments, which sometimes ar treated as HTML tags, and even if not, they are always ignored and never displayed.
所以,我需要在插入电子邮件正文之前转义此列。
So, I need to escape this column before inserting into email body.
是否有一个函数可以转义html特殊字符自动进入实体?
或者我需要手动将所有特殊字符替换('<','& lt,',string)
Is there a function to escape html special chars into entities automaticly?
Or do I need to replace('<', '<', string)
manually all the special characters?
推荐答案
您可以使用htf.escape_sc函数:
You can use the htf.escape_sc function:
SQL> select htf.escape_sc('Please escape <this> tag') from dual;
HTF.ESCAPE_SC('PLEASEESCAPE<THIS>TAG')
------------------------------------------------------------------
Please escape <this> tag
这篇关于如何逃避<>和&字符到Oracle PL / SQL中的html实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!