Decode Numeric HTML Entities in ColdFusion?

前端 未结 4 1429
花落未央
花落未央 2020-12-06 12:15

I need a way to transform numeric HTML entities into their plain-text character equivalent. For example, I would like to turn the entity:

é
         


        
4条回答
  •  悲哀的现实
    2020-12-06 12:44

    Updated Answer:

    Thanks to Todd Sharp for pointing out a very simple way to do this, using the Apache Commons StringEscapeUtils library, which is packaged with CF (and Railo), so you can just do:

    
    
    
    



    Original Answer:

    That linked function is icky - there's no need to name them explicitly, and as you say it doesn't do numerics.

    Much simpler is to let CF do the work for you - using the XmlParse function:

    
        
        #Arguments.Entity#').XmlRoot.XmlText />
    
    

    That one works with Railo, I can't remember if CF supports that syntax yet though, so you might need to change it to:

    
        
        #Arguments.Entity#') />
        
    
    

提交回复
热议问题