How to get an html encoded character to stay encoded?

Discussion in 'Programming' started by simmy, Sep 11, 2007.

  1. #1
    I am trying to replace a series of characters with an html encoded string value and use that to look for a value in a table. My problem is that when I put the encoded value in the replace function, cf converts it to the character instead of leaving it as those characters.

    Example
    Let say Passname = "%E2%84%A2Hello"
    I have the code:
    <cfset PassName=#Replace(PassName, "%E2%84%A2", "&##153;","all")#>
    this will make the string passname contain: "â„¢Hello". I want it to be "&##153;Hello" (remove the extra # for the correct result)

    Is there any way to do this?

    Thanks
    Simmy
     
    simmy, Sep 11, 2007 IP
  2. Jamie18

    Jamie18 Peon

    Messages:
    201
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    my guess is that the PassName variable actually does contain "&##153;Hello" but when you're outputting it is getting changed to the evaluated version of &##153;+Hello

    if what you're looking to do is simply output the variable you could probably do something like this wherever it is outputted
    <cfoutput>#replace(PassName,"&", "&amp;)#</cfoutput>
     
    Jamie18, Sep 11, 2007 IP
  3. Jamie18

    Jamie18 Peon

    Messages:
    201
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    whoops something i did in that last line turned into a smiley face.. here it is again

    
    <cfoutput>#replace(PassName,"&", "&amp;", "all")#</cfoutput>
    
    Code (markup):
     
    Jamie18, Sep 11, 2007 IP