Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Coldfusion not converting accented text or MS Word chars

Running Coldfusion 8, I am trying to clean text input before saving to a database that will take things like the MS equivalent of ' " - and accented letters, and converting them.

I have tried replace, REReplace, and various UDFs found on the internet. None seem to work. In fact, I tried this:

<cfscript>
    function cleanString(string) {
       var newString = string;
       newString = replace("'", "'", ALL);
       return newString; 
    }
</cfscript>

The single quote to be replaced above is a MS Word style single quote. Coldfusion threw an error, the error scope said invalid syntax and the single quote in the error scope was a square. If I change it to the chr() form, and replace with ', I get a blank. If I do chr() to the entity, I get a blank.

I am more than certain I have jumped this hurdle before, and not sure why nothing is working now. Is there a new setting in CF8 vs CF7 regarding character encoding that I am missing?

like image 606
Kevin Avatar asked May 06 '10 17:05

Kevin


1 Answers

There is a great script for demoronizing (yes, that's a technical term) text copied from MS word and the like. It can be found at CFLib:
http://cflib.org/index.cfm?event=page.udfbyid&udfid=725

I've used it several times, and been happy with it out-of-the-box (though I have added some additions for specific applications).

like image 130
Ben Doom Avatar answered Nov 09 '22 00:11

Ben Doom