0

For example when i printing:

System.out.println("I".toLowerCase()+ "İ".toLowerCase())

I get this:

i i̇

Well, they are not the same, but there is a problem, the lowercase of these letters I İ is - ı i.

How to get the same letters? with no dot?

Maroun
  • 94,125
  • 30
  • 188
  • 241
  • You may want to look here: https://stackoverflow.com/questions/10336730/which-locale-should-i-specify-when-i-call-string-tolowercase – Michael Berry Apr 27 '20 at 12:52
  • It depends on the font you are using.... – Josteve Apr 27 '20 at 12:52
  • The lowercase of a letter is Locale dependant (there is a reason why [.toLowerCase accepts a locale as an argument](https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#toLowerCase(java.util.Locale))). In most latin-alphabet languages (French, Spanish, ... but also English or German), the lowercase of `I` is `i`, with a dot. In turkish, the dotted and non dotted `I` (upper or lower case) are *entirely different* letters. https://en.wikipedia.org/wiki/Dotted_and_dotless_I . So... what is your goal ? – GPI Apr 27 '20 at 12:52
  • this I is latin, so you need to convert it. – Infern0 Apr 27 '20 at 12:52
  • What locale are you using in your program? You can set the default locale like this: `Locale.setDefault(new Locale("pt", "BR"));`. You can also provide a locale in the call to `toLowerCase`. More info [here](https://stackoverflow.com/questions/8809098/how-do-i-set-the-default-locale-in-the-jvm). – Lii Apr 27 '20 at 12:59

2 Answers2

2

"Normally" (read: in almost all locales) the lower-case of I (Unicode character U+0049 LATIN CAPITAL LETTER I, ASCII 73) is i (Unicode character U+0069 LATIN SMALL LETTER I, ASCII 105).

In some locales (as far as I know only Turkish and Azerbaijan locales) the lower-case of U+0049 I is U+0131 LATIN SMALL LETTER DOTLESS I.

So neither answer is technically right or wrong in all cases.

To get the desired result, you need to specify the intended locale to the toLowerCase method:

String turkishLowerCase = "I".toLowerCase(Locale.forLanguageTag("tr-TR");
String englishLowerCase = "I".toLowerCase(Locale.forLanguageTag("en-US");

turkishLowerCase will be ı and englishLowerCase will be i.

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
-1

With the latin alphabet the Letter "I" is "i" in lowercase.

You can use a localized version of toLowerCase to resolve your issue.

System.out.println("I".toLocaleLowerCase()+ "İ".toLocaleLowerCase()); 

If that doesn't help you, you should replace them manually:

System.out.println("I".replaceAll("I", "ı")+ "İ".replaceAll("İ", "i"));
MarvinJWendt
  • 2,357
  • 1
  • 10
  • 36