W3cubDocs

/Kotlin

isWhitespace

Platform and version requirements: JVM (1.0), JS (1.1), Native (1.3)
fun Char.isWhitespace(): Boolean
For JVM

Determines whether a character is whitespace according to the Unicode standard. Returns true if the character is whitespace.

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

fun main(args: Array<String>) {
//sampleStart
val chars = listOf(' ', '\t', '\n', '1', 'a', '\u00A0')
val (whitespaces, notWhitespaces) = chars.partition { it.isWhitespace() }
// whitespace char codes
println(whitespaces.map(Char::toInt)) // [32, 9, 10, 160]
// non-whitespace chars
println(notWhitespaces) // [1, a]
//sampleEnd
}
For Native

Determines whether a character is whitespace according to the Unicode standard. Returns true if the character is whitespace.

© 2010–2020 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/is-whitespace.html