Jonathan Ellis
07/21/2022, 1:40 PM'capitalize(): String' is deprecated. Use replaceFirstChar insteadwhat is the thinking here?
replaceFirstChar { if (it.isLowerCase()) it.titlecase() else it.toString() }
is a lot clunkiermkrussel
07/21/2022, 1:45 PMJonathan Ellis
07/21/2022, 1:46 PMMiSikora
07/21/2022, 1:48 PMcapitialize()
being ambiguous - https://kotlinlang.slack.com/archives/C0B8Q383C/p1621263607077700Jonathan Ellis
07/21/2022, 1:50 PMMiSikora
07/21/2022, 1:50 PMJonathan Ellis
07/21/2022, 1:51 PMMiSikora
07/21/2022, 1:52 PMJonathan Ellis
07/21/2022, 1:54 PMMiSikora
07/21/2022, 2:00 PMcapitalize()
behaves differently in Kotlin from the languages that you mentionedJonathan Ellis
07/21/2022, 2:00 PMMiSikora
07/21/2022, 2:01 PMDŽ
and see the results. In Kotlin it isn’t transformed to Dž
Jonathan Ellis
07/21/2022, 2:03 PMMiSikora
07/21/2022, 2:03 PMJoffrey
07/21/2022, 2:22 PMJonathan Ellis
07/21/2022, 2:23 PMFleshgrinder
07/21/2022, 4:59 PM.capitalize().decapitalize()
) due to language rules? And, and, and, …
This are decisions only a user can make in their unique context and domain. Even things like case conversions have to be interpreted differently in different contexts (especially the roundtrip thing). Yes, it is a burden for users. But, having some implementation that works for everyone across the multiplatform world (where not even all targets have support for locales/language tags, and do not have Unicode databases) is simply impossible.
Check out https://github.com/Kotlin/KEEP/issues/223 to catch up on the decision making.
If JVM is all you care about then I would recommend Intl ICU. It contains all the advanced things to work with text.
If ASCII is all you care about you can just uppercase the first and substring the rest.
If …