isWhitespace

Determines whether the Unicode character corresponding to this code point is whitespace.

A character is considered whitespace if either its Unicode category is one of CharCategory.SPACE_SEPARATOR, CharCategory.LINE_SEPARATOR, CharCategory.PARAGRAPH_SEPARATOR, or it is a CharCategory.CONTROL character in range U+0009..U+000D or U+001C..U+001F.

Returns true if the character is whitespace.

Since Kotlin

2.5

Samples

import kotlin.text.unicode.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   val string = "\r\n😁\t\t\u00a0Kotlin"
val withoutWhitespace = string.asCodePointSequence().filterNot { it.isWhitespace() }.joinToString("")
println(withoutWhitespace) // 😁Kotlin 
   //sampleEnd
}

Determines whether the Unicode character corresponding to this code point is whitespace.

A character is considered whitespace if either its Unicode category is one of CharCategory.SPACE_SEPARATOR, CharCategory.LINE_SEPARATOR, CharCategory.PARAGRAPH_SEPARATOR, or it is a CharCategory.CONTROL character in range U+0009..U+000D or U+001C..U+001F.

Returns true if the character is whitespace.

Since Kotlin

2.5

Samples

import kotlin.text.unicode.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   val string = "\r\n😁\t\t\u00a0Kotlin"
val withoutWhitespace = string.asCodePointSequence().filterNot { it.isWhitespace() }.joinToString("")
println(withoutWhitespace) // 😁Kotlin 
   //sampleEnd
}