Stripping certain ASCII characters for XML file
How would I make sure that any output I save to a file (CFFile) is restricted to characters 32-126 of the 127 US_ASCII approved characters? I'm currently using Repace("xxx","yyy","zzz","all") to replace / escape some characters (like "" to "amp;") for an XML file. Paul Sizemore Finish Line 3308 N Mitthoeffer Rd Indianapolis, IN 46235 W: 317-899-1022 ext 3516 ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Stripping certain ASCII characters for XML file
What you really want to do (if you're going to XML) is replace those characters with numeric entities (XML will bomb on HTML entities unless you explicitly declare them in your DTD, or use an HTML compliant DTD) Hence your your amp; is #38;, your non-breaking space is #160; (i think) and not nbsp; etc. The easiest way to do this is replace(chr(x),"##" x ";", mystring, "ALL") You can do this in a loop where x=127 to 254 (but make sure to hit your "" at 38, etc.) getting your amps; and nbsp; to numeric entities is a little more involved -- you basically run through an array of replaces where arr[n] is the HTML entity for chr(n). Somewhere I have a custom tag called cf_makeEntitiesNumeric that does this, and I can dig it up if you need it. Michael Caulfield -Original Message- From: Paul Sizemore [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 12, 2001 11:53 AM To: CF-Talk Subject: Stripping certain ASCII characters for XML file How would I make sure that any output I save to a file (CFFile) is restricted to characters 32-126 of the 127 US_ASCII approved characters? I'm currently using Repace("xxx","yyy","zzz","all") to replace / escape some characters (like "" to "amp;") for an XML file. Paul Sizemore Finish Line 3308 N Mitthoeffer Rd Indianapolis, IN 46235 W: 317-899-1022 ext 3516 ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: Stripping certain ASCII characters for XML file
Paul, You might want to look at the XMLFormat function. It may do what you need. Tim P. - Original Message - From: "Paul Sizemore" [EMAIL PROTECTED] To: "CF-Talk" [EMAIL PROTECTED] Sent: Thursday, April 12, 2001 12:52 PM Subject: Stripping certain ASCII characters for XML file How would I make sure that any output I save to a file (CFFile) is restricted to characters 32-126 of the 127 US_ASCII approved characters? I'm currently using Repace("xxx","yyy","zzz","all") to replace / escape some characters (like "" to "amp;") for an XML file. Paul Sizemore Finish Line 3308 N Mitthoeffer Rd Indianapolis, IN 46235 W: 317-899-1022 ext 3516 ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Stripping certain ASCII characters for XML file
Keep in mind, though, that XMLFormat("nbsp;") gives you amp;nbsp; which is often not what you want. (which is to say the offer of CF_makeEntitiesNumeric still stands if you need it) Michael Caulfield -Original Message- From: Tim Painter [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 12, 2001 12:34 PM To: CF-Talk Subject: Re: Stripping certain ASCII characters for XML file Paul, You might want to look at the XMLFormat function. It may do what you need. Tim P. - Original Message - From: "Paul Sizemore" [EMAIL PROTECTED] To: "CF-Talk" [EMAIL PROTECTED] Sent: Thursday, April 12, 2001 12:52 PM Subject: Stripping certain ASCII characters for XML file How would I make sure that any output I save to a file (CFFile) is restricted to characters 32-126 of the 127 US_ASCII approved characters? I'm currently using Repace("xxx","yyy","zzz","all") to replace / escape some characters (like "" to "amp;") for an XML file. Paul Sizemore Finish Line 3308 N Mitthoeffer Rd Indianapolis, IN 46235 W: 317-899-1022 ext 3516 ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Stripping certain ASCII characters for XML file
The XMLFormat function Rocks, I wish I had know about it before I strung together all those CF Replace functions. Also, I needed the XML reserved taken care of as well as ASCII 127 and up removed. I think the following code does that for me. cfset item_short_desc="""ØÞÒú '" cfloop index="ASCIIChars" from="127" to="254" step="1" cfset item_short_desc= #Replace("#item_short_desc#", "#chr(ASCIIChars)#", " ", "ALL")# /cfloop cfset item_short_desc = #xmlFormat(#item_short_desc#)# Thanks Tim and Michael Paul -Original Message- From: Tim Painter [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 12, 2001 12:34 PM To: CF-Talk Subject: Re: Stripping certain ASCII characters for XML file Paul, You might want to look at the XMLFormat function. It may do what you need. Tim P. - Original Message - From: "Paul Sizemore" [EMAIL PROTECTED] To: "CF-Talk" [EMAIL PROTECTED] Sent: Thursday, April 12, 2001 12:52 PM Subject: Stripping certain ASCII characters for XML file How would I make sure that any output I save to a file (CFFile) is restricted to characters 32-126 of the 127 US_ASCII approved characters? I'm currently using Repace("xxx","yyy","zzz","all") to replace / escape some characters (like "" to "amp;") for an XML file. Paul Sizemore Finish Line 3308 N Mitthoeffer Rd Indianapolis, IN 46235 W: 317-899-1022 ext 3516 ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Stripping certain ASCII characters for XML file
Michael If the offer is open I wouldn't mind getting the tag from you, sound very useful. Rodney -Original Message- From: Caulfield, Michael [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 12, 2001 10:29 AM To: CF-Talk Subject: RE: Stripping certain ASCII characters for XML file What you really want to do (if you're going to XML) is replace those characters with numeric entities (XML will bomb on HTML entities unless you explicitly declare them in your DTD, or use an HTML compliant DTD) Hence your your amp; is #38;, your non-breaking space is #160; (i think) and not nbsp; etc. The easiest way to do this is replace(chr(x),"##" x ";", mystring, "ALL") You can do this in a loop where x=127 to 254 (but make sure to hit your "" at 38, etc.) getting your amps; and nbsp; to numeric entities is a little more involved -- you basically run through an array of replaces where arr[n] is the HTML entity for chr(n). Somewhere I have a custom tag called cf_makeEntitiesNumeric that does this, and I can dig it up if you need it. Michael Caulfield -Original Message- From: Paul Sizemore [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 12, 2001 11:53 AM To: CF-Talk Subject: Stripping certain ASCII characters for XML file How would I make sure that any output I save to a file (CFFile) is restricted to characters 32-126 of the 127 US_ASCII approved characters? I'm currently using Repace("xxx","yyy","zzz","all") to replace / escape some characters (like "" to "amp;") for an XML file. Paul Sizemore Finish Line 3308 N Mitthoeffer Rd Indianapolis, IN 46235 W: 317-899-1022 ext 3516 ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists