uppercase

Common
JVM
JS
Native
1.5

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
}
Common
JVM
JS
Native
1.5

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
}
JVM
1.5
fun Char.uppercase(locale: Locale): String
(source)

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
}
JVM
1.5
fun String.uppercase(locale: Locale): String
(source)

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
}