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>

Comments

  1. That is a very helpful little piece of code. Thanks very much.

    ReplyDelete
  2. Thank you! Very precious code!

    ReplyDelete
  3. This is exactly what I needed to fix a the output of a utf-8 XML file corrupted with Non ascii charaters. Thanks

    ReplyDelete

Post a Comment

Popular posts from this blog

how to add new line in google form questions | Fix for next line issue in google form questions

How to add new line in dropdown type question in google forms