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

Replacing non-ascii characters in String

Guest
May 15, 2008 May 15, 2008

Copy link to clipboard

Copied

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

Views

2.3K

Translate

Translate

Report

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

Copy link to clipboard

Copied

rereplace might work.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

quote:

Originally posted by: Dan Bracuk
rereplace might work.


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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

This might work:

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


Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST
This worked:

REReplace(string, '[^\x00-\x7F]', ' ', "ALL")

Votes

Translate

Translate

Report

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
Documentation