titlecase
Converts this character to title case using Unicode mapping rules of the invariant locale.
This function supports one-to-many character mapping, thus the length of the returned string can be greater than one. For example, '\uFB00'.titlecase()
returns "\u0046\u0066"
, where '\uFB00'
is the LATIN SMALL LIGATURE FF character (ο¬
). If this character has no title case mapping, the result of uppercase is returned instead.
Since Kotlin
1.5Samples
import java.util.*
import kotlin.test.*
fun main() {
//sampleStart
val chars = listOf('a', 'Η
', 'Ε', '+', 'Γ')
val titlecaseChar = chars.map { it.titlecaseChar() }
val titlecase = chars.map { it.titlecase() }
println(titlecaseChar) // [A, Η
, Ε, +, Γ]
println(titlecase) // [A, Η
, ΚΌN, +, Ss]
//sampleEnd
}
Converts this character to title case using Unicode mapping rules of the specified locale.
This function supports one-to-many character mapping, thus the length of the returned string can be greater than one. For example, '\uFB00'.titlecase(Locale.US)
returns "\u0046\u0066"
, where '\uFB00'
is the LATIN SMALL LIGATURE FF character (ο¬
). If this character has no title case mapping, the result of uppercase(locale)
is returned instead.
Since Kotlin
1.5Samples
import java.util.*
import kotlin.test.*
fun main() {
//sampleStart
val chars = listOf('a', 'Η
', 'Ε', '+', 'Γ', 'i')
val titlecase = chars.map { it.titlecase() }
val turkishLocale = Locale.forLanguageTag("tr")
val titlecaseTurkish = chars.map { it.titlecase(turkishLocale) }
println(titlecase) // [A, Η
, ΚΌN, +, Ss, I]
println(titlecaseTurkish) // [A, Η
, ΚΌN, +, Ss, Δ°]
//sampleEnd
}