fun CPointer<ByteVar>.toKString(): String
Return the kotlin.String decoded from given zero-terminated UTF-8-encoded C string.
fun ByteArray.toKString(): String
Decodes a string from the bytes in UTF-8 encoding in this array. Bytes following the first occurrence of 0
byte, if it occurs, are not decoded.
Malformed byte sequences are replaced by the replacement char \uFFFD
.
fun ByteArray.toKString( startIndex: Int = 0, endIndex: Int = this.size, throwOnInvalidSequence: Boolean = false ): String
Decodes a string from the bytes in UTF-8 encoding in this array or its subrange. Bytes following the first occurrence of 0
byte, if it occurs, are not decoded.
startIndex
- the beginning (inclusive) of the subrange to decode, 0 by default.
endIndex
- the end (exclusive) of the subrange to decode, size of this array by default.
throwOnInvalidSequence
- specifies whether to throw an exception on malformed byte sequence or replace it by the replacement char \uFFFD
.
IndexOutOfBoundsException
- if startIndex is less than zero or endIndex is greater than the size of this array.
IllegalArgumentException
- if startIndex is greater than endIndex.
CharacterCodingException
- if the byte array contains malformed UTF-8 byte sequence and throwOnInvalidSequence is true.
fun CPointer<ShortVar>.toKString(): String
fun CPointer<UShortVar>.toKString(): String
© 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/kotlinx.cinterop/to-k-string.html