Skip to main content
May 15, 2008
Question

Replacing non-ascii characters in String

  • May 15, 2008
  • 4 replies
  • 3006 views
I have a site where the user enters data in a rich text editor (ktml4) that gets stored into a database (mysql). There are non ascii characters getting into the data, I'm assuming that they are copying and pasting from Word. Unfortunately in this situation, changing that process isn't an option.

Currently, this is the only character that is causing me problems: http://www.zvon.org/other/charSearch/PHP/search.php?request=ffa0&searchType=3

I would just like to replace the non-ascii characters with a space when I read them from the database. Something like:

#Replace(result.column, '\xffa0', ' ')#


However, I believe that code looks for the string "\xffa0", not the character \xffa0.

Is there anyway to do this?
This topic has been closed for replies.

4 replies

May 18, 2008
This worked:

REReplace(string, '[^\x00-\x7F]', ' ', "ALL")
BKBK
Community Expert
Community Expert
May 18, 2008
This might work:

<cfset toBase10 = inputbasen("FFA0",16)>
<cfset newResult = ReplaceNoCase(result.column, chr(toBase10), ' ',"all")>


Inspiring
May 16, 2008
Inspiring
May 15, 2008
rereplace might work.
May 15, 2008
quote:

Originally posted by: Dan Bracuk
rereplace might work.


Can you give an example of how to pass a non-ascii character to REReplace?
Inspiring
May 15, 2008
quote:

Originally posted by: BuckLemke
quote:

Originally posted by: Dan Bracuk
rereplace might work.


Can you give an example of how to pass a non-ascii character to REReplace?

Regular expressions are not my strength, but the approach I was considering was, "if it's not an ascii character, make it a space". Then you pass the entire string at once.