Skip to main content
Participant
May 7, 2006
Question

special character

  • May 7, 2006
  • 2 replies
  • 307 views
I have text that has literal < and/or > used to describe less than or greater than. I can not control the users for using these characters. It is stored and retrieved from SQL 2005. However, when using cfdocument and cfoutput to prepare document the < character disappears and whatever is after it. Is my only option to Replace() these character with espace like \<??

Thank you
Haluk
    This topic has been closed for replies.

    2 replies

    May 8, 2006
    If you are using cfdocument or if you are just displaying the data you might be able to wrap your string in an htmleditformat() function. For example: #HMTLEditFormat(string)#.
    Participating Frequently
    May 8, 2006
    To my knowledge you have to do something like this

    #Replace( Replace( text, "<", "&lt;", "ALL"), ">", "&gt;", "ALL")#

    Which translates to: Go through the contents of text and replace all instances of < with &lt; (which is the escape sequence for < ) and then goes through the result of that and replaces all instances of > with &gt; (which is the escape sequence for > )

    I had to do something similar with a site where I wanted users to be able to enter the source code for C++ programs (which contains angle brackets too).