Is there any way to dynamically replace accented characters such as the following?
requesón => requeson
What I mean is that every accented (or whatever) character would be replaced with the normal one.
Is this possible using ColdFusion?
You can fix accented characters through java text normalization and a regex. There is a function on cflib that does this already:
From: http://cflib.org/udf/deAccent
function deAccent(str){
//based on the approach found here: http://stackoverflow.com/a/1215117/894061
var Normalizer = createObject("java","java.text.Normalizer");
var NormalizerForm = createObject("java","java.text.Normalizer$Form");
var normalizedString = Normalizer.normalize(str, createObject("java","java.text.Normalizer$Form").NFD);
var pattern = createObject("java","java.util.regex.Pattern").compile("\p{InCombiningDiacriticalMarks}+");
return pattern.matcher(normalizedString).replaceAll("");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With