Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d5a46cb

Browse files
zgnmggozgungoksenli
andauthored
Add turkist to latin conversion (TheAlgorithms#2332)
Co-authored-by: Özgün Gökşenli <ogoksenli@kocfinans.com.tr>
1 parent c850415 commit d5a46cb

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package Conversions;
2+
3+
import java.util.Scanner;
4+
5+
/**
6+
* Converts turkish character to latin character
7+
*
8+
* @author Özgün Gökşenli
9+
*/
10+
public class TurkishToLatinConversion {
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+
}
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;
38+
}
39+
}
40+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /