Converting Non-ASCII code to ASCII equivalent in terms of look
Asked Answered
D

1

3

I have thousands of name in a mysql database that have the extended ASCII code in them. I want to convert them to a normal english alphabet. Here is an example :

Indāpur Jejūri convert to -> Indapur Jejuri

So how can I do it ? I know Java and Groovy, and a bunch of other scripting languages but didn't have much luck. Any suggestion ?

Democratic answered 24/3, 2014 at 1:41 Comment(3)
Presumably you'd get a 64K-entry translation table and translate.Ixia
Python has unidecode, which probably has some sort of Java equivalent.Spectre
PHP answer here: #158741Encase
D
4

I found the answer after going through many posts in stackoverflow : Converting Symbols, Accent Letters to English Alphabet

import java.text.Normalizer;
import java.util.regex.Pattern;

public String deAccent(String str) {
    String nfdNormalizedString = Normalizer.normalize(str, Normalizer.Form.NFD); 
    Pattern pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
    return pattern.matcher(nfdNormalizedString).replaceAll("");
}
Democratic answered 24/3, 2014 at 14:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.