Char
class Char : Comparable<Char>
For Common, JVM, JS
Represents a 16-bit Unicode character.
On the JVM, non-nullable values of this type are represented as values of the primitive type char
.
For Native
Represents a 16-bit Unicode character.
Functions
compareTo
Compares this value with the specified value for order.
fun compareTo(other: Char): Int
dec
Decrements this value.
operator fun dec(): Char
equals
fun equals(other: Char): Boolean
Indicates whether some other object is "equal to" this one. Implementations must fulfil the following requirements:
fun equals(other: Any?): Boolean
hashCode
Returns a hash code value for the object. The general contract of hashCode
is:
fun hashCode(): Int
inc
Increments this value.
operator fun inc(): Char
minus
Subtracts the other Char value from this value resulting an Int.
operator fun minus(other: Char): Int
Subtracts the other Int value from this value resulting a Char.
operator fun minus(other: Int): Char
plus
Adds the other Int value to this value resulting a Char.
operator fun plus(other: Int): Char
toByte
Returns the value of this character as a Byte
.
fun toByte(): Byte
toChar
Returns the value of this character as a Char
.
fun toChar(): Char
toDouble
Returns the value of this character as a Double
.
fun toDouble(): Double
toFloat
Returns the value of this character as a Float
.
fun toFloat(): Float
toInt
Returns the value of this character as a Int
.
fun toInt(): Int
toLong
Returns the value of this character as a Long
.
fun toLong(): Long
toShort
Returns the value of this character as a Short
.
fun toShort(): Short
toString
Returns a string representation of the object.
fun toString(): String
Companion Object Properties
MAX_CODE_POINT
The maximum value of a Unicode code point. Kotlin/Native specific.
const val MAX_CODE_POINT: Int
MAX_HIGH_SURROGATE
The maximum value of a Unicode high-surrogate code unit.
const val MAX_HIGH_SURROGATE: Char
MAX_LOW_SURROGATE
The maximum value of a Unicode low-surrogate code unit.
const val MAX_LOW_SURROGATE: Char
MAX_RADIX
The maximum radix available for conversion to and from strings.
const val MAX_RADIX: Int
MAX_SURROGATE
The maximum value of a Unicode surrogate code unit.
const val MAX_SURROGATE: Char
MAX_VALUE
The maximum value of a character code unit.
const val MAX_VALUE: Char
MIN_CODE_POINT
The minimum value of a Unicode code point. Kotlin/Native specific.
const val MIN_CODE_POINT: Int
MIN_HIGH_SURROGATE
The minimum value of a Unicode high-surrogate code unit.
const val MIN_HIGH_SURROGATE: Char
MIN_LOW_SURROGATE
The minimum value of a Unicode low-surrogate code unit.
const val MIN_LOW_SURROGATE: Char
MIN_RADIX
The minimum radix available for conversion to and from strings.
const val MIN_RADIX: Int
MIN_SUPPLEMENTARY_CODE_POINT
The minimum value of a supplementary code point, \u0x10000
. Kotlin/Native specific.
const val MIN_SUPPLEMENTARY_CODE_POINT: Int
MIN_SURROGATE
The minimum value of a Unicode surrogate code unit.
const val MIN_SURROGATE: Char
MIN_VALUE
The minimum value of a character code unit.
const val MIN_VALUE: Char
SIZE_BITS
The number of bits used to represent a Char in a binary form.
const val SIZE_BITS: Int
SIZE_BYTES
The number of bytes used to represent a Char in a binary form.
const val SIZE_BYTES: Int
Extension Properties
directionality
Returns the Unicode directionality property for the given character.
val Char.directionality: CharDirectionality
Extension Functions
coerceAtLeast
Ensures that this value is not less than the specified minimumValue.
fun <T : Comparable<T>> T.coerceAtLeast(minimumValue: T): T
coerceAtMost
Ensures that this value is not greater than the specified maximumValue.
fun <T : Comparable<T>> T.coerceAtMost(maximumValue: T): T
coerceIn
Ensures that this value lies in the specified range minimumValue..maximumValue.
fun <T : Comparable<T>> T.coerceIn(
minimumValue: T?,
maximumValue: T?
): T
Ensures that this value lies in the specified range.
fun <T : Comparable<T>> T.coerceIn(
range: ClosedFloatingPointRange<T>
): T
fun <T : Comparable<T>> T.coerceIn(range: ClosedRange<T>): T
downTo
Returns a progression from this value down to the specified to value with the step -1.
infix fun Char.downTo(to: Char): CharProgression
equals
Returns true
if this character is equal to the other character, optionally ignoring character case.
fun Char.equals(
other: Char,
ignoreCase: Boolean = false
): Boolean
isJavaIdentifierPart
Returns true
if this character (Unicode code point) may be part of a Java identifier as other than the first character.
fun Char.isJavaIdentifierPart(): Boolean
isJavaIdentifierStart
Returns true
if this character is permissible as the first character in a Java identifier.
fun Char.isJavaIdentifierStart(): Boolean
isSurrogate
Returns true
if this character is a Unicode surrogate code unit.
fun Char.isSurrogate(): Boolean
isTitleCase
Returns true
if this character is a titlecase character.
fun Char.isTitleCase(): Boolean
plus
Concatenates this Char and a String.
operator fun Char.plus(other: String): String
rangeTo
Creates a range from this Comparable value to the specified that value.
operator fun <T : Comparable<T>> T.rangeTo(
that: T
): ClosedRange<T>
toTitleCase
Converts this character to titlecase.
fun Char.toTitleCase(): Char
Companion Object Extension Functions
isSupplementaryCodePoint
Checks if the codepoint specified is a supplementary codepoint or not.
fun Char.Companion.isSupplementaryCodePoint(
codepoint: Int
): Boolean
isSurrogatePair
fun Char.Companion.isSurrogatePair(
high: Char,
low: Char
): Boolean
toCodePoint
Converts a surrogate pair to a unicode code point. Doesn't validate that the characters are a valid surrogate pair.
fun Char.Companion.toCodePoint(high: Char, low: Char): Int