Coldfusion not converting accented text or MS Word chars

别说谁变了你拦得住时间么 提交于 2019-12-07 05:19:44

问题


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?


回答1:


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).



来源:https://stackoverflow.com/questions/2783230/coldfusion-not-converting-accented-text-or-ms-word-chars

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!