RandyLahey
RandyLahey

Reputation: 979

How to decode French html entities in Coldfusion

I have tried a couple different things including urldecode() as well as a few different answers from this question: Decode Numeric HTML Entities in ColdFusion?

For example I have this french text:

 Après avoir terminé

I need to convert to the actual french characters, including the space at the beginning to this:

 Après avoir terminé

Any ideas? Thanks in advance.

Upvotes: 2

Views: 576

Answers (1)

Peter Boughton
Peter Boughton

Reputation: 112220

You can use the Apache Commons library to do this:

<cfset input = "&nbsp;Apr&egrave;s avoir termin&eacute;" />
<cfset utils = createObject("java", "org.apache.commons.lang.StringEscapeUtils") />
<cfdump var=#utils.unescapeHTML(input)# />

(p.s. This was hidden in a comment to my answer on the question you linked to, though I've since edited into the main answer to increase visibility.)

Upvotes: 7

Related Questions