Hi All,
I have some raw data coming from a column in a database that contains the
following data (code):
<table cellspacing="0" border="0" cellpadding="0" width="100%"
bgcolor="white"><tr><td width="30%">&nbsp;</td><td
width="70%">&nbsp;</td></tr><TR><TD><font face="arial"
size="2"><b>Name:</b></font></TD><<TD><font face="arial"
size="2"><b>Email:</b></font></TD> (bla, bla, bla and so on...)
Unfortunately, when I query the data and output it, it returns (outputs) the
following:
<table cellspacing="0" border="0" cellpadding="0" width="100%"
bgcolor="white"><tr><td width="30%"></td><td
width="70%"></td></tr><tr><td><font face="arial"
size="2">[B]Name:[/B]</font></td><<td><font face="arial"
size="2">[B]Email:[/B]</font></td> (bla, bla, bla and so on...)
I've tried to use the URLDecode function to decode it but doesn't work. Is
there a way or a CF function that I can use to convert these special charaters,
"<", ">", "&nbsp;" to " < ", " > ", " " respectively without using
the ReplaceNoCase function which is what I'm doing now (see below):
<CFSET HTML_Content = Trim(GetHTMLContent.HTML_Content)>
<CFSET HTML_Content = ReplaceNoCase(HTML_Content,"<","<","ALL")>
<CFSET HTML_Content = ReplaceNoCase(HTML_Content,">",">","ALL")>
<CFSET HTML_Content = ReplaceNoCase(HTML_Content,"&##39;","'","ALL")>
<CFSET HTML_Content = ReplaceNoCase(HTML_Content,"&nbsp;"," ","ALL")>
<CFOUTPUT>#HTML_Content#</CFOUTPUT>
Many thanks in advance!
BKBK - 27 Jan 2007 11:01 GMT
http://livedocs.macromedia.com/coldfusion/7/htmldocs/00000506.htm
<cfset rawData='<table cellspacing="0" border="0" cellpadding="0"
width="100%" bgcolor="white"><tr><td
width="30%">&nbsp;</td><td
width="70%">&nbsp;</td></tr><TR><TD><font
face="arial"
size="2"><b>Name:</b></font></TD><<TD><fo
nt face="arial" size="2"><b>Email:</b></font></TD>
(bla, bla, bla and so on...)'>
<p>
<strong>without htmlEditFormat:</strong><br>
<cfoutput>#rawData#</cfoutput>
</p>
<strong>with htmlEditFormat:</strong><br>
<cfoutput>#htmlEditFormat(rawData)#</cfoutput>
AppDeveloper - 29 Jan 2007 21:49 GMT
Hi BKBK,
Your suggestion is not working. Any other advice?
Many thanks!
BKBK - 30 Jan 2007 05:54 GMT
Copy-and-paste the code I've given, and save it as [i]entityTest.cfm[/i]. Run it and you will find that it works.
AppDeveloper - 30 Jan 2007 19:55 GMT
Hi BKBK,
I copied your code and ran it, but it shows this "<table cellspacing="0"
border="0" cellpadding="0" width="100%" bgcolor="white"><tr><td
width="30%"> </td><td width="70%"> </td></tr><TR><TD><font
face="arial" size="2">[B]Name:[/B]</font></TD><<TD><font face="arial"
size="2">[B]Email:[/B]</font></TD> (bla, bla, bla and so on...) " when running
it on the browser. I want the code rendered out as an html page with 2 columns
"Name" and "Email" in a table.
Thanks.
BKBK - 30 Jan 2007 21:24 GMT
It wasn't clear to me you wanted to produce a table. Here then is an idea
<cfset rawData='<table cellspacing="0" border="1" cellpadding="0" width="100%"
bgcolor="white"><tr><td width="30%">&nbsp;</td><td
width="70%">&nbsp;</td></tr><TR><TD><font face="arial"
size="2"><b>Name:</b></font></TD><TD><font face="arial"
size="2"><b>Email:</b></font></TD></TR></table> '>
<cfset rawData = replaceNoCase(rawData,"<","<","all")>
<cfset rawData = replaceNoCase(rawData,">",">","all")>
<cfset rawData = replaceNoCase(rawData,"&","&","all")>
<cfoutput>#rawData#</cfoutput>
[CJ] - 31 Jan 2007 00:54 GMT
as far as i know, there's no built in function to unescape the escaped HTML
characters.
i think your replace() functions will be the way to go. I know it's not
pretty...but you could always just wrap that into a UDF so at least it's
modular.
BKBK - 31 Jan 2007 06:22 GMT
AppDeveloper, I realize just now that what you had done [i]did work[/i], and
you were only looking for an alternative. I missed your point right from the
beginning. Sorry about that. As they say, when one picks the wrong branch at a
junction, any further step only takes one further away from one's destination.