How could I replace accents with normal characters in DB2?
For example: ëèé
becomes eee
edit: I could use the REPLACE
function in my function but I don't want to catch ALL the possibilites because it seems endless to me.
How could I replace accents with normal characters in DB2?
For example: ëèé
becomes eee
edit: I could use the REPLACE
function in my function but I don't want to catch ALL the possibilites because it seems endless to me.
One idea is to write a java function like: http://www.drillio.com/en/software-development/java/removing-accents-diacritics-in-any-language/
public static String removeAccents(String text) {
return text == null ? null
: Normalizer.normalize(text, Form.NFD)
.replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
}
Now you can register that function in DB2 and use it from sql. See sqlj.install_jar in db2 documentation
There is not an utility for this replacement, because this is not something generic, but a very specific case.
For example, in French we have: çàéèùêô€œ
In Spanish we have: áéíóúñüÑ
German and Danish have different characters.
Even some English words have foreign chars: façade.
How are you going to translate them? Even if it seem endless you have to provide your own replacement. First, you need to create a matching list for the language you are going to translate, and then create that endless list.
BTW, why do you want to translate them? Any well application supports Unicode, only old or bad applications do not support Unicode correctly.
Finally, you can create a more flexible method to change characters if you use Regular Expression. And in DB2, you can use them with xQuery.