capitalize

@DeprecatedSinceKotlin(warningSince = "1.5")
expect fun String.capitalize(): String

Returns a copy of this string having its first letter titlecased using the rules of the default locale, or the original string if it's empty or already starts with a title case letter.

The title case of a character is usually the same as its upper case with several exceptions. The particular list of characters with the special title case form depends on the underlying platform.

Samples

import samples.*
import java.util.Locale
import kotlin.test.*
fun main() { 
   //sampleStart 
   assertPrints("abcd".capitalize(), "Abcd")
assertPrints("Abcd".capitalize(), "Abcd") 
   //sampleEnd
}
@DeprecatedSinceKotlin(warningSince = "1.5")
fun String.capitalize(locale: Locale): String

Returns a copy of this string having its first letter titlecased using the rules of the specified locale, or the original string if it's empty or already starts with a title case letter.

The title case of a character is usually the same as its upper case with several exceptions. The particular list of characters with the special title case form depends on the underlying platform.

Since Kotlin

1.4

@DeprecatedSinceKotlin(warningSince = "1.5")
actual fun String.capitalize(): String

Returns a copy of this string having its first letter titlecased using the rules of the default locale, or the original string if it's empty or already starts with a title case letter.

The title case of a character is usually the same as its upper case with several exceptions. The particular list of characters with the special title case form depends on the underlying platform.

Samples

import samples.*
import java.util.Locale
import kotlin.test.*
fun main() { 
   //sampleStart 
   assertPrints("abcd".capitalize(), "Abcd")
assertPrints("Abcd".capitalize(), "Abcd") 
   //sampleEnd
}
@DeprecatedSinceKotlin(warningSince = "1.5")
actual fun String.capitalize(): String

Returns a copy of this string having its first letter titlecased using the rules of the default locale, or the original string if it's empty or already starts with a title case letter.

The title case of a character is usually the same as its upper case with several exceptions. The particular list of characters with the special title case form depends on the underlying platform.

Samples

import samples.*
import java.util.Locale
import kotlin.test.*
fun main() { 
   //sampleStart 
   assertPrints("abcd".capitalize(), "Abcd")
assertPrints("Abcd".capitalize(), "Abcd") 
   //sampleEnd
}
@DeprecatedSinceKotlin(warningSince = "1.5")
actual fun String.capitalize(): String

Returns a copy of this string having its first letter titlecased using the rules of the default locale, or the original string if it's empty or already starts with a title case letter.

The title case of a character is usually the same as its upper case with several exceptions. The particular list of characters with the special title case form depends on the underlying platform.

Samples

import samples.*
import java.util.Locale
import kotlin.test.*
fun main() { 
   //sampleStart 
   assertPrints("abcd".capitalize(), "Abcd")
assertPrints("Abcd".capitalize(), "Abcd") 
   //sampleEnd
}