Remove non ASCII characters in coldfusion
The following code will remove the non ascii or illegal characters from a string.
<cfset str=" Please enter string ">
<cfset a=reReplace(str, "[^\x20-\x7E]", "", "ALL")>
<cfoutput>#a#</cfoutput>
<cfset str=" Please enter string ">
<cfset a=reReplace(str, "[^\x20-\x7E]", "", "ALL")>
<cfoutput>#a#</cfoutput>
That is a very helpful little piece of code. Thanks very much.
ReplyDeleteThank you! Very precious code!
ReplyDeleteThis is exactly what I needed to fix a the output of a utf-8 XML file corrupted with Non ascii charaters. Thanks
ReplyDeletehappy to hear that..
Delete