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.5

Samples

import java.util.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   val chars = listOf('a', 'Dž', 'ʼn', '+', 'ß')
val titlecaseChar = chars.map { it.titlecaseChar() }
val titlecase = chars.map { it.titlecase() }
println(titlecaseChar) // [A, Dž, ʼn, +, ß]
println(titlecase) // [A, Dž, ʼ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.5

Samples

import java.util.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   val chars = listOf('a', 'Dž', 'ʼn', '+', 'ß', 'i')
val titlecase = chars.map { it.titlecase() }
val turkishLocale = Locale.forLanguageTag("tr")
val titlecaseTurkish = chars.map { it.titlecase(turkishLocale) }
println(titlecase) // [A, Dž, ʼN, +, Ss, I]
println(titlecaseTurkish) // [A, Dž, ʼN, +, Ss, İ] 
   //sampleEnd
}