uppercase

Platform and version requirements: JVM (1.5), JS (1.5), Native (1.5)
fun Char.uppercase(): String

Converts this character to upper 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'.uppercase() returns "\u0046\u0046", where '\uFB00' is the LATIN SMALL LIGATURE FF character (). If this character has no upper case mapping, the result of toString() of this char is returned.

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

fun main(args: Array<String>) {
//sampleStart
val chars = listOf('a', 'ω', '1', 'ʼn', 'A', '+', 'ß')
val uppercaseChar = chars.map { it.uppercaseChar() }
val uppercase = chars.map { it.uppercase() }
println(uppercaseChar) // [A, Ω, 1, ʼn, A, +, ß]
println(uppercase) // [A, Ω, 1, ʼN, A, +, SS]
//sampleEnd
}
Platform and version requirements: JVM (1.5), JS (1.5), Native (1.5)
fun String.uppercase(): String

Returns a copy of this string converted to upper case using Unicode mapping rules of the invariant locale.

This function supports one-to-many and many-to-one character mapping, thus the length of the returned string can be different from the length of the original string.

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

fun main(args: Array<String>) {
//sampleStart
println("Iced frappé!".uppercase()) // ICED FRAPPÉ!
//sampleEnd
}
Platform and version requirements: JVM (1.5)
fun Char.uppercase(locale: Locale): String

Converts this character to upper 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'.uppercase(Locale.US) returns "\u0046\u0046", where '\uFB00' is the LATIN SMALL LIGATURE FF character (). If this character has no upper case mapping, the result of toString() of this char is returned.

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

fun main(args: Array<String>) {
//sampleStart
val chars = listOf('a', '1', 'ʼn', 'A', '+', 'i')
val uppercase = chars.map { it.uppercase() }
val turkishLocale = Locale.forLanguageTag("tr")
val uppercaseTurkish = chars.map { it.uppercase(turkishLocale) }
println(uppercase) // [A, 1, ʼN, A, +, I]
println(uppercaseTurkish) // [A, 1, ʼN, A, +, İ]
//sampleEnd
}
Platform and version requirements: JVM (1.5)
fun String.uppercase(locale: Locale): String

Returns a copy of this string converted to upper case using the rules of the specified locale.

This function supports one-to-many and many-to-one character mapping, thus the length of the returned string can be different from the length of the original string.

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

fun main(args: Array<String>) {
//sampleStart
println("Kotlin".uppercase()) // KOTLIN
val turkishLocale = Locale.forLanguageTag("tr")
println("Kotlin".uppercase(turkishLocale)) // KOTLİN
//sampleEnd
}

© 2010–2021 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/uppercase.html