Fix titlecase lowering in decapitalize
Replace isUpperCase() with !isLowerCase check to lower both upper- and titlecased first chars.
This commit is contained in:
@@ -609,7 +609,7 @@ public actual fun String.decapitalize(): String {
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalStdlibApi
|
||||
public fun String.decapitalize(locale: Locale): String {
|
||||
return if (isNotEmpty() && this[0].isUpperCase()) substring(0, 1).toLowerCase(locale) + substring(1) else this
|
||||
return if (isNotEmpty() && !this[0].isLowerCase()) substring(0, 1).toLowerCase(locale) + substring(1) else this
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -93,5 +93,9 @@ class StringJVMTest {
|
||||
// Locale-specific case mappings.
|
||||
assertEquals("ıII", "III".decapitalize(Locale("tr", "TR")))
|
||||
assertEquals("iII", "III".decapitalize(Locale.US))
|
||||
|
||||
// Case mapping where title case is different than uppercase.
|
||||
assertEquals("dzdzdz", "DZdzdz".decapitalize(Locale.US))
|
||||
assertEquals("dzdzdz", "Dzdzdz".decapitalize(Locale.US))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user