|
9 | 9 | */ |
10 | 10 | public class TurkishToLatinConversion { |
11 | 11 |
|
12 | | - /** |
13 | | - * Main method |
14 | | - * |
15 | | - * @param args Command line arguments |
16 | | - */ |
17 | | - public static void main(String args[]) { |
18 | | - Scanner sc = new Scanner(System.in); |
19 | | - System.out.println("Input the string: "); |
20 | | - String b = sc.next(); |
21 | | - System.out.println("Converted: " + convertTurkishToLatin(b)); |
22 | | - sc.close(); |
23 | | - } |
| 12 | + /** |
| 13 | + * Main method |
| 14 | + * |
| 15 | + * @param args Command line arguments |
| 16 | + */ |
| 17 | + public static void main(String args[]) { |
| 18 | + Scanner sc = new Scanner(System.in); |
| 19 | + System.out.println("Input the string: "); |
| 20 | + String b = sc.next(); |
| 21 | + System.out.println("Converted: " + convertTurkishToLatin(b)); |
| 22 | + sc.close(); |
| 23 | + } |
24 | 24 |
|
25 | | - /** |
26 | | - * This method converts a turkish character to latin character. |
27 | | - * |
28 | | - * @param param String paramter |
29 | | - * @return String |
30 | | - */ |
31 | | - public static String convertTurkishToLatin(String param) { |
32 | | - char[] turkishChars = new char[]{0x131, 0x130, 0xFC, 0xDC, 0xF6, 0xD6, 0x15F, 0x15E, 0xE7, 0xC7, 0x11F, 0x11E}; |
33 | | - char[] latinChars = new char[]{'i', 'I', 'u', 'U', 'o', 'O', 's', 'S', 'c', 'C', 'g', 'G'}; |
34 | | - for (int i = 0; i < turkishChars.length; i++) { |
35 | | - param = param.replaceAll(new String(new char[]{turkishChars[i]}), new String(new char[]{latinChars[i]})); |
36 | | - } |
37 | | - return param; |
| 25 | + /** |
| 26 | + * This method converts a turkish character to latin character. |
| 27 | + * |
| 28 | + * @param param String paramter |
| 29 | + * @return String |
| 30 | + */ |
| 31 | + public static String convertTurkishToLatin(String param) { |
| 32 | + char[] turkishChars = |
| 33 | + new char[] {0x131, 0x130, 0xFC, 0xDC, 0xF6, 0xD6, 0x15F, 0x15E, 0xE7, 0xC7, 0x11F, 0x11E}; |
| 34 | + char[] latinChars = new char[] {'i', 'I', 'u', 'U', 'o', 'O', 's', 'S', 'c', 'C', 'g', 'G'}; |
| 35 | + for (int i = 0; i < turkishChars.length; i++) { |
| 36 | + param = |
| 37 | + param.replaceAll( |
| 38 | + new String(new char[] {turkishChars[i]}), new String(new char[] {latinChars[i]})); |
38 | 39 | } |
| 40 | + return param; |
| 41 | + } |
39 | 42 | } |
40 | | - |
|
0 commit comments