|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
XMLFormatted Characters
Hi All,Duane Boudreau 01/06/09 09:18 A Not a direct answer, but you could not touch the special characters (notAdrian Lynch 02/05/09 04:45 A Don't destroy raw data - only do formatting when outputting.Peter Boughton 02/05/09 08:35 A Hi All, I?m using XMLFormat to convert special characters in strings to their HTML equivalents. This works fine as long as the strings are being displayed in plain HTML but causes problems when I try to output the strings in using an alert box. Does know how to convert XMLFormatted characters back to their original form? ex: ó to รณ Thanks, Duane Not a direct answer, but you could not touch the special characters (not sure why they're called special characters, they're not THAT special!) and instead use CDATA islands when generating the XML files. Adrian ----- Excess quoted text cut - see Original Post for more ----- Don't destroy raw data - only do formatting when outputting. Also, many people recommend HtmlEditFormat over XmlFormat for outputting to HTML. So, if you have an original variable HtmlData containing unescaped characters... - Use HtmlEditFormat(HtmlData) to convert for HTML output. - And JsStringFormat(HtmlData) to display in a JS alert box. (although I'm not sure why the JS alert isn't dealing with the entities properly.) If you do actually need to convert from HTML entity to actual character... I'd probably use a Java Regex replace with a callback function. That could fix any hex or decimal entities easily enough, with just a little bit more effort required to compile a lookup for named entities. (If anyone wants to go that route and can't find an existing function, I don't mind throwing it together (later tonight), but only if I'm not reinventing a wheel that already exists - i.e. someone search cflib/etc and if there's nothing on there I'll add one)
|
March 21, 2010
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||