House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Search cf-talk

July 04, 2009

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31   

Home /  Groups /  ColdFusion Talk (CF-Talk)

XMLFormatted Characters

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Hi All,
Duane Boudreau
01/06/09 09:18 A
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Duane Boudreau
01/06/2009 09:18 AM

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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Adrian Lynch
02/05/2009 04:45 AM

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 -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Peter Boughton
02/05/2009 08:35 AM

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)


<< Previous Thread Today's Threads Next Thread >>

Mailing Lists