Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Replacing non-ascii characters in String

Guest
May 15, 2008 May 15, 2008
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?
TOPICS
Advanced techniques
2.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 15, 2008 May 15, 2008
rereplace might work.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 15, 2008 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?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 15, 2008 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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
May 16, 2008 May 16, 2008
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 18, 2008 May 18, 2008
This might work:

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


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 18, 2008 May 18, 2008
LATEST
This worked:

REReplace(string, '[^\x00-\x7F]', ' ', "ALL")
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources