diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/io/JceInput.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/io/JceInput.kt index c1b790589..b778ecbac 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/io/JceInput.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/io/JceInput.kt @@ -3,6 +3,7 @@ package net.mamoe.mirai.qqandroid.network.io import kotlinx.io.charsets.Charset import kotlinx.io.core.* import kotlinx.io.pool.ObjectPool +import net.mamoe.mirai.utils.io.readIoBuffer import net.mamoe.mirai.utils.io.readString import net.mamoe.mirai.utils.io.toIoBuffer @@ -20,6 +21,8 @@ inline class JceHead(private val value: Long) { fun ByteArray.asJceInput(charset: Charset = CharsetGBK): JceInput = JceInput(this.toIoBuffer(), charset) +fun ByteReadPacket.asJceInput(charset: Charset = CharsetGBK): JceInput = JceInput(this.readIoBuffer(), charset) + @Suppress("MemberVisibilityCanBePrivate") @UseExperimental(ExperimentalUnsignedTypes::class) class JceInput( diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/io/JceOutput.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/io/JceOutput.kt index d55b49a1b..3e12d45fd 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/io/JceOutput.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/io/JceOutput.kt @@ -7,6 +7,8 @@ import kotlin.reflect.KClass @PublishedApi internal val CharsetGBK = Charset.forName("GBK") +@PublishedApi +internal val CharsetUTF8 = Charset.forName("UTF8") inline fun buildJcePacket(stringCharset: Charset = CharsetGBK, block: JceOutput.() -> Unit): ByteReadPacket { return JceOutput(stringCharset).apply(block).build()