-5

I am trying to covert string to local case.

Is it possible to convert a string to lower case internationally not just for specific locale.

Patan
  • 17,073
  • 36
  • 124
  • 198
  • Can you please elaborate on what you mean by "lower case internationally" and how `String#toLowerCase()` does not achieve what you need? – hiergiltdiestfu Aug 27 '15 at 09:57
  • [here](http://stackoverflow.com/a/11063161/1638708) is some information why using Locales makes sense – User42 Aug 27 '15 at 09:58
  • Why -5? I don't see this as a poor question. When I first saw the windows api for case conversion, I immediately thought "what on earth is this"? – Bathsheba Aug 27 '15 at 10:07
  • @Bathsheba, there is just so much on the internet (and on SO) about this, just google it. (...not that I voted it down) – User42 Aug 27 '15 at 10:16
  • 1
    Looks very much like an XY problem. It’s not clear what the actual problem is, i.e. why you need to convert the string to lowercase at all. – Holger Aug 27 '15 at 11:00

1 Answers1

4

No, it would be meaningless.

How do you deal, for example, with the German ß, or other alphabets?

You always need a locale to do the job properly, unless, of course, you're satisfied with mapping [A - Z] to [a - z], in which case String#toLowerCase will do the job.

Bathsheba
  • 231,907
  • 34
  • 361
  • 483
  • 1
    Absolutely. That only exists as a lower case letter. – Bathsheba Aug 27 '15 at 09:58
  • Well, it's got an upper case variant defined in unicode, but that's basically not used _at all_. https://en.wikipedia.org/wiki/Capital_%E1%BA%9E – hiergiltdiestfu Aug 27 '15 at 09:59
  • 1
    Before the introduction of the uppercase `ß`, there was no uppercase `ß`, regardless of which locale you use, so I don’t see how this proves the necessity of a locale-sensitive mapping. – Holger Aug 27 '15 at 10:52
  • 1
    No German typesetter would use the upper case ß: they would substitute SS which will lengthen the string! How about the Norwegian slashed o then (both upper and lower case)? There are so many edge cases. Doesn't Turkish also have letters that don't exist in both cases? – Bathsheba Aug 27 '15 at 11:03
  • 1
    `Ø` maps to `ø` the same way `ä` maps to `Ä` or `Ω` maps to `ω` and `Щ` maps to `щ`. All of them are locale-independent as 99.9% are. You will have a hard time finding other examples besides the famous Turkish mapping of `İ` to `i` and `I` to `ı`. Unless you look into the implementation of `String.toLowercase` as there are so little differences that they are actually hardcoded: if the language is one of `"tr"`, `"az"` or `"lt"` and the character is either `'Σ'` or `İ`, conditional code will be entered, in all other cases, there will be no difference at all… – Holger Aug 27 '15 at 12:20
  • 1
    By the way, as of Java 8, `ß` will indeed get mapped to `SS`, regardless of the `Locale`… – Holger Aug 27 '15 at 12:24