• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

converting characters

Participant ,
Mar 12, 2008 Mar 12, 2008

Copy link to clipboard

Copied

I've tried bunch of string functions but I couldn't get it to work, I am trying to convert something like:
None &lt;/div&gt; INTO None &</div&>
so it would display correctly on the page.
Is my only option that's left Replace or is there an actual function that would do this?
TOPICS
Advanced techniques

Views

361

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 12, 2008 Mar 12, 2008

Copy link to clipboard

Copied

TiGGi wrote:
> I've tried bunch of string functions but I couldn't get it to work, I am trying
> to convert something like:
> None &lt;/div&gt; INTO None &</div&>
> so it would display correctly on the page.
> Is my only option that's left Replace or is there an actual function that
> would do this?
>


Which way are you trying to get to display. I would expect the first
example to display correctly in a browser as it is escaped. Are you
trying to escape mark up do that is displays the code or to un-escaped
the content so that it is rendered or just display the output?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 12, 2008 Mar 12, 2008

Copy link to clipboard

Copied

I would like it to display as un-escaped, so it will only show text and not html code.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 12, 2008 Mar 12, 2008

Copy link to clipboard

Copied

TiGGi wrote:
> I would like it to display as un-escaped, so it will only show text and not html code.


Sorry, I am not aware of any built-in reverse to the HTMLeditFormat()
and HTMLcodeFormat() functions. You might try the cflib.org site to see
if anybody has created one already. Otherwise show you code and we can
try and help you role your own solution.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 13, 2008 Mar 13, 2008

Copy link to clipboard

Copied

You can use ReplaceList to get it to replace the escape characters, something like:

str=ListReplace(str,"&,&gt;,&lt;","&,>,<")

You can expand the lists to include all special characters. You'll also have to run the code multiple times, given your example. The first time you run it &lt;/div&gt; will get converted to &lt;/div&gt; The second time you should get </div>. To run it multiple times, you can use a while loop with a regular expression. Something like:

<cfloop condition="ReFind('\&[^;\s]+\;',str, 0, 0)"></cfloop>

Forgive me if the code is not exactly right, I didn't test it, but you should get the idea.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 13, 2008 Mar 13, 2008

Copy link to clipboard

Copied

LATEST
Thank you for your help!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation