Transliterate English text using the Greek alphabet: Difference between revisions
Content added Content deleted
(New post.) |
m (Minor code improvement.) |
||
Line 150: | Line 150: | ||
public static void main(String[] args) { |
public static void main(String[] args) { |
||
List<String> tests = List.of( |
List<String> tests = List.of( |
||
"The quick brown fox |
"The quick brown fox jumps over the lazy dog.", // Note: "jumps" not "jumped" |
||
""" |
""" |
||
I was looking at some rhododendrons in my back garden, |
I was looking at some rhododendrons in my back garden, |
||
Line 176: | Line 176: | ||
for ( String test : tests ) { |
for ( String test : tests ) { |
||
String greek = test; |
String greek = test; |
||
⚫ | |||
⚫ | |||
⚫ | |||
for ( int i = 0; i < greek.length(); i++ ) { |
for ( int i = 0; i < greek.length(); i++ ) { |
||
if ( greek.charAt(i) == ' |
if ( greek.charAt(i) == 's' && ! Character.isAlphabetic(greek.charAt(i + 1)) ) { |
||
greek = greek.substring(0, i) + 'ς' + greek.substring(i + 1); |
greek = greek.substring(0, i) + 'ς' + greek.substring(i + 1); |
||
} |
} |
||
} |
} |
||
⚫ | |||
⚫ | |||
⚫ | |||
} |
|||
System.out.println(test + System.lineSeparator() + " =>" + System.lineSeparator() + greek); |
System.out.println(test + System.lineSeparator() + " =>" + System.lineSeparator() + greek); |
||
System.out.println("=".repeat(65)); |
System.out.println("=".repeat(65)); |
||
Line 193: | Line 193: | ||
</syntaxhighlight> |
</syntaxhighlight> |
||
<pre> |
<pre> |
||
The quick brown fox |
The quick brown fox jumps over the lazy dog. |
||
=> |
=> |
||
Θε κυικ βροων ϕοξ |
Θε κυικ βροων ϕοξ ιυμπς οβερ θε λαζυ δογ. |
||
================================================================= |
================================================================= |
||
I was looking at some rhododendrons in my back garden, |
I was looking at some rhododendrons in my back garden, |