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): Intdec
Decrements this value.
operator fun dec(): Charequals
fun equals(other: Char): BooleanIndicates whether some other object is "equal to" this one. Implementations must fulfil the following requirements:
fun equals(other: Any?): BooleanhashCode
Returns a hash code value for the object. The general contract of hashCode is:
fun hashCode(): Intinc
Increments this value.
operator fun inc(): Charminus
Subtracts the other Char value from this value resulting an Int.
operator fun minus(other: Char): IntSubtracts the other Int value from this value resulting a Char.
operator fun minus(other: Int): Charplus
Adds the other Int value to this value resulting a Char.
operator fun plus(other: Int): ChartoByte
Returns the value of this character as a Byte.
fun toByte(): BytetoChar
Returns the value of this character as a Char.
fun toChar(): ChartoDouble
Returns the value of this character as a Double.
fun toDouble(): DoubletoFloat
Returns the value of this character as a Float.
fun toFloat(): FloattoInt
Returns the value of this character as a Int.
fun toInt(): InttoLong
Returns the value of this character as a Long.
fun toLong(): LongtoShort
Returns the value of this character as a Short.
fun toShort(): ShorttoString
Returns a string representation of the object.
fun toString(): StringCompanion Object Properties
MAX_CODE_POINT
The maximum value of a Unicode code point. Kotlin/Native specific.
const val MAX_CODE_POINT: IntMAX_HIGH_SURROGATE
The maximum value of a Unicode high-surrogate code unit.
const val MAX_HIGH_SURROGATE: CharMAX_LOW_SURROGATE
The maximum value of a Unicode low-surrogate code unit.
const val MAX_LOW_SURROGATE: CharMAX_RADIX
The maximum radix available for conversion to and from strings.
const val MAX_RADIX: IntMAX_SURROGATE
The maximum value of a Unicode surrogate code unit.
const val MAX_SURROGATE: CharMAX_VALUE
The maximum value of a character code unit.
const val MAX_VALUE: CharMIN_CODE_POINT
The minimum value of a Unicode code point. Kotlin/Native specific.
const val MIN_CODE_POINT: IntMIN_HIGH_SURROGATE
The minimum value of a Unicode high-surrogate code unit.
const val MIN_HIGH_SURROGATE: CharMIN_LOW_SURROGATE
The minimum value of a Unicode low-surrogate code unit.
const val MIN_LOW_SURROGATE: CharMIN_RADIX
The minimum radix available for conversion to and from strings.
const val MIN_RADIX: IntMIN_SUPPLEMENTARY_CODE_POINT
The minimum value of a supplementary code point, \u0x10000. Kotlin/Native specific.
const val MIN_SUPPLEMENTARY_CODE_POINT: IntMIN_SURROGATE
The minimum value of a Unicode surrogate code unit.
const val MIN_SURROGATE: CharMIN_VALUE
The minimum value of a character code unit.
const val MIN_VALUE: CharSIZE_BITS
The number of bits used to represent a Char in a binary form.
const val SIZE_BITS: IntSIZE_BYTES
The number of bytes used to represent a Char in a binary form.
const val SIZE_BYTES: IntExtension Properties
directionality
Returns the Unicode directionality property for the given character.
val Char.directionality: CharDirectionalityExtension Functions
coerceAtLeast
Ensures that this value is not less than the specified minimumValue.
fun <T : Comparable<T>> T.coerceAtLeast(minimumValue: T): TcoerceAtMost
Ensures that this value is not greater than the specified maximumValue.
fun <T : Comparable<T>> T.coerceAtMost(maximumValue: T): TcoerceIn
Ensures that this value lies in the specified range minimumValue..maximumValue.
fun <T : Comparable<T>> T.coerceIn(
minimumValue: T?,
maximumValue: T?
): TEnsures that this value lies in the specified range.
fun <T : Comparable<T>> T.coerceIn(
range: ClosedFloatingPointRange<T>
): Tfun <T : Comparable<T>> T.coerceIn(range: ClosedRange<T>): TdownTo
Returns a progression from this value down to the specified to value with the step -1.
infix fun Char.downTo(to: Char): CharProgressionequals
Returns true if this character is equal to the other character, optionally ignoring character case.
fun Char.equals(
other: Char,
ignoreCase: Boolean = false
): BooleanisJavaIdentifierPart
Returns true if this character (Unicode code point) may be part of a Java identifier as other than the first character.
fun Char.isJavaIdentifierPart(): BooleanisJavaIdentifierStart
Returns true if this character is permissible as the first character in a Java identifier.
fun Char.isJavaIdentifierStart(): BooleanisSurrogate
Returns true if this character is a Unicode surrogate code unit.
fun Char.isSurrogate(): BooleanisTitleCase
Returns true if this character is a titlecase character.
fun Char.isTitleCase(): Booleanplus
Concatenates this Char and a String.
operator fun Char.plus(other: String): StringrangeTo
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(): CharCompanion Object Extension Functions
isSupplementaryCodePoint
Checks if the codepoint specified is a supplementary codepoint or not.
fun Char.Companion.isSupplementaryCodePoint(
codepoint: Int
): BooleanisSurrogatePair
fun Char.Companion.isSurrogatePair(
high: Char,
low: Char
): BooleantoCodePoint
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