Introduce basic, url-safe and mime Base64 variants #KT-9823

This commit is contained in:
Abduqodiri Qurbonzoda
2022-11-22 15:34:19 +02:00
committed by Space Team
parent a5c8e30bb1
commit dc03a03762
13 changed files with 1898 additions and 1 deletions
@@ -0,0 +1,46 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package kotlin.io.encoding
@SinceKotlin("1.8")
@ExperimentalStdlibApi
@kotlin.internal.InlineOnly
internal actual inline fun Base64.platformCharsToBytes(source: CharSequence, startIndex: Int, endIndex: Int): ByteArray {
return charsToBytesImpl(source, startIndex, endIndex)
}
@SinceKotlin("1.8")
@ExperimentalStdlibApi
@kotlin.internal.InlineOnly
internal actual inline fun Base64.platformEncodeToString(source: ByteArray, startIndex: Int, endIndex: Int): String {
val byteResult = encodeToByteArrayImpl(source, startIndex, endIndex)
return bytesToStringImpl(byteResult)
}
@SinceKotlin("1.8")
@ExperimentalStdlibApi
@kotlin.internal.InlineOnly
internal actual inline fun Base64.platformEncodeIntoByteArray(
source: ByteArray,
destination: ByteArray,
destinationOffset: Int,
startIndex: Int,
endIndex: Int
): Int {
return encodeIntoByteArrayImpl(source, destination, destinationOffset, startIndex, endIndex)
}
@SinceKotlin("1.8")
@ExperimentalStdlibApi
@kotlin.internal.InlineOnly
internal actual inline fun Base64.platformEncodeToByteArray(
source: ByteArray,
startIndex: Int,
endIndex: Int
): ByteArray {
return encodeToByteArrayImpl(source, startIndex, endIndex)
}