Replace graphic accent diacritic Java Function

Replace diacritic marks: Á Č Ď É Ě Í Ň Ó Ř Š Ť Ú Ů Ý Ž
á č ď é ě í ň ó ř š ť ú ů ý ž

public String replaceDiacritic (String inputStr) {
 
	Map<String, String> replacements = new LinkedHashMap<String,String>() {{
		//Velká
		put("Á","A");
		put("Č","C");
		put("Ď","D");
		put("É","E");
		put("Ě","E");
		put("Í","I");
		put("Ň","N");
		put("Ó","O");
		put("Ř","R");
		put("Š","S");
		put("Ť","T");
		put("Ú","U");
		put("Ů","U");
		put("Ý","Y");
		put("Ž","Z");
		//Malá  "," ");
		put("á","a");
		put("č","c");
		put("ď","d");
		put("é","e");
		put("ě","e");
		put("í","i");
		put("ň","n");
		put("ó","o");
		put("ř","r");
		put("š","s");
		put("ť","t");
		put("ú","u");
		put("ů","u");
		put("ý","y");
		put("ž","z");
		}
	};
	for(Map.Entry<String, String> entry : replacements.entrySet()) {
          inputStr =  inputStr.replaceAll(entry.getKey(), entry.getValue());
         }	
	return inputStr;
}
This entry was posted in Android Examples Code and tagged . Bookmark the permalink.


Comments are closed.

3,292 views