Created
September 29, 2020 17:09
-
-
Save nickname55/a4ab842e82be1388cd5e0bf8714c0314 to your computer and use it in GitHub Desktop.
transliterate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Test { | |
| public static void main(String[] args) { | |
| System.out.println(transliterate("жыра")); | |
| } | |
| public static String transliterate(String message){ | |
| char[] abcCyr = {' ','а','б','в','г','д','е','ё', 'ж','з','и','й','к','л','м','н','о','п','р','с','т','у','ф','х', 'ц','ч', 'ш','щ','ъ','ы','ь','э', 'ю','я','А','Б','В','Г','Д','Е','Ё', 'Ж','З','И','Й','К','Л','М','Н','О','П','Р','С','Т','У','Ф','Х', 'Ц', 'Ч','Ш', 'Щ','Ъ','Ы','Ь','Э','Ю','Я','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'}; | |
| String[] abcLat = {" ","a","b","v","g","d","e","e","zh","z","i","y","k","l","m","n","o","p","r","s","t","u","f","h","ts","ch","sh","sch", "","i", "","e","ju","ja","A","B","V","G","D","E","E","Zh","Z","I","Y","K","L","M","N","O","P","R","S","T","U","F","H","Ts","Ch","Sh","Sch", "","I", "","E","Ju","Ja","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"}; | |
| StringBuilder builder = new StringBuilder(); | |
| for (int i = 0; i < message.length(); i++) { | |
| for (int x = 0; x < abcCyr.length; x++ ) { | |
| if (message.charAt(i) == abcCyr[x]) { | |
| builder.append(abcLat[x]); | |
| } | |
| } | |
| } | |
| return builder.toString(); | |
| } | |
| public static String belrusToEngTranlit (String text){ | |
| char[] abcCyr = {'a','б','в','г','д','ё','ж','з','и','к','л','м','н','п','р','с','т','у','ў','ф','х','ц','ш','щ','ы','э','ю','я'}; | |
| String[] abcLat = {"a","b","v","g","d","jo","zh","z","i","k","l","m","n","p","r","s","t","u","w","f","h","ts","sh","sch","","e","ju","ja"}; | |
| StringBuilder builder = new StringBuilder(); | |
| for (int i = 0; i < text.length(); i++) { | |
| for(int x = 0; x < abcCyr.length; x++ ) | |
| if (text.charAt(i) == abcCyr[x]) { | |
| builder.append(abcLat[x]); | |
| } | |
| } | |
| return builder.toString(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment