How do I translate a string into translit? For example: BIT1-15 -> BIT1-15 Maybe some algorithm or library already exists?

    2 answers 2

    And what you do not like something like this:

    HashMap<string, string> alph = new Map<string, string>; aplh.put("а", "а"); aplh.put("b", "б"); aplh.put("c", "ц"); aplh.put("d", "д"); aplh.put("th", "с"); .... string str = "БИТ1-15"; for(int i=0; i<alph.keySet.size(); i++) str = str.replace(alph.keySet[i], alph[alph.keySet[i]]); return str; 
    • I think that there will be a lot of counter examples. - Ramil Gabdrakhmanov
    • It seems to me that this is the simplest solution. I do not argue that something more intelligent and correct can be invented, but for the example that the author cited, it should work fine. - Rennorb

    I advise you to look at the article . Yes, there is on js, but the code is clear. Can be easily ported to Java