From 71afd112c6058e2e39e35dab30b81c1a9bce8729 Mon Sep 17 00:00:00 2001 From: Abduqodiri Qurbonzoda Date: Sat, 27 Mar 2021 04:00:22 +0300 Subject: [PATCH] [K/N] Remove old String and utf8 conversion api #KT-31343 --- .../src/main/kotlin/kotlin/Exceptions.kt | 8 -- .../src/main/kotlin/kotlin/native/Text.kt | 117 ------------------ 2 files changed, 125 deletions(-) diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt index db829929c1c..678199c761c 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt @@ -166,14 +166,6 @@ public actual open class NumberFormatException : IllegalArgumentException { actual constructor(message: String?) : super(message) } -@Deprecated("Use CharacterCodingException instead", ReplaceWith("CharacterCodingException"), DeprecationLevel.ERROR) -public open class IllegalCharacterConversionException : IllegalArgumentException { - - constructor(): super() - - constructor(message: String?) : super(message) -} - public actual open class ConcurrentModificationException actual constructor(message: String?, cause: Throwable?) : RuntimeException(message, cause) { diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/Text.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/Text.kt index dca59618736..faa85c04087 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/Text.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/Text.kt @@ -5,123 +5,6 @@ package kotlin.native -import kotlinx.cinterop.toKString - -/** - * Converts an UTF-8 array into a [String]. Replaces invalid input sequences with a default character. - */ -@Deprecated( - "Use toKString or decodeToString instead", - ReplaceWith("toKString()", "kotlinx.cinterop.toKString"), - DeprecationLevel.ERROR -) -public fun ByteArray.stringFromUtf8() : String { - @Suppress("DEPRECATION_ERROR") - return this.stringFromUtf8(0, this.size) -} - -/** - * Converts an UTF-8 array into a [String]. Replaces invalid input sequences with a default character. - */ -@Deprecated( - "Use toKString or decodeToString instead", - ReplaceWith("toKString(start, start + size)", "kotlinx.cinterop.toKString"), - DeprecationLevel.ERROR -) -public fun ByteArray.stringFromUtf8(start: Int = 0, size: Int = this.size) : String { - return toKString(start, start + size) -} - -/** - * Converts an UTF-8 array into a [String]. - * @throws [IllegalCharacterConversionException] if the input is invalid. - */ -@Deprecated( - "Use toKString or decodeToString instead", - ReplaceWith("toKString(throwOnInvalidSequence = true)", "kotlinx.cinterop.toKString"), - DeprecationLevel.ERROR -) -public fun ByteArray.stringFromUtf8OrThrow() : String { - @Suppress("DEPRECATION_ERROR") - return this.stringFromUtf8OrThrow(0, this.size) -} - -/** - * Converts an UTF-8 array into a [String]. - * @throws [IllegalCharacterConversionException] if the input is invalid. - */ -@Deprecated( - "Use toKString or decodeToString instead", - ReplaceWith("toKString(start, start + size, throwOnInvalidSequence = true)", "kotlinx.cinterop.toKString"), - DeprecationLevel.ERROR -) -public fun ByteArray.stringFromUtf8OrThrow(start: Int = 0, size: Int = this.size) : String { - try { - return toKString(start, start + size, throwOnInvalidSequence = true) - } catch (e: CharacterCodingException) { - @Suppress("DEPRECATION_ERROR") - throw IllegalCharacterConversionException() - } -} - -/** - * Converts a [String] into an UTF-8 array. Replaces invalid input sequences with a default character. - */ -@Deprecated( - "Use encodeToByteArray instead", - ReplaceWith("encodeToByteArray()"), - DeprecationLevel.ERROR -) -public fun String.toUtf8() : ByteArray { - @Suppress("DEPRECATION_ERROR") - return this.toUtf8(0, this.length) -} - -/** - * Converts a [String] into an UTF-8 array. Replaces invalid input sequences with a default character. - */ -@Deprecated( - "Use encodeToByteArray instead", - ReplaceWith("encodeToByteArray(start, start + size)"), - DeprecationLevel.ERROR -) -public fun String.toUtf8(start: Int = 0, size: Int = this.length) : ByteArray { - checkBoundsIndexes(start, start + size, this.length) - return unsafeStringToUtf8(start, size) -} - -/** - * Converts a [String] into an UTF-8 array. - * @throws [IllegalCharacterConversionException] if the input is invalid. - */ -@Deprecated( - "Use encodeToByteArray instead", - ReplaceWith("encodeToByteArray(throwOnInvalidSequence = true)"), - DeprecationLevel.ERROR -) -public fun String.toUtf8OrThrow() : ByteArray { - @Suppress("DEPRECATION_ERROR") - return this.toUtf8OrThrow(0, this.length) -} - -/** - * Converts a [String] into an UTF-8 array. - * @throws [IllegalCharacterConversionException] if the input is invalid. - */ -@Deprecated( - "Use encodeToByteArray instead", - ReplaceWith("encodeToByteArray(start, start + size, throwOnInvalidSequence = true)"), - DeprecationLevel.ERROR -) -public fun String.toUtf8OrThrow(start: Int = 0, size: Int = this.length) : ByteArray { - checkBoundsIndexes(start, start + size, this.length) - try { - return unsafeStringToUtf8OrThrow(start, size) - } catch (e: CharacterCodingException) { - @Suppress("DEPRECATION_ERROR") - throw IllegalCharacterConversionException() - } -} internal fun checkBoundsIndexes(startIndex: Int, endIndex: Int, size: Int) { if (startIndex < 0 || endIndex > size) {