[K/N] Remove old String and utf8 conversion api #KT-31343

This commit is contained in:
Abduqodiri Qurbonzoda
2021-03-27 04:00:22 +03:00
parent e8992c5d19
commit 71afd112c6
2 changed files with 0 additions and 125 deletions
@@ -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) {
@@ -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) {