From f1dfca2154665347db2741c36ca2c532f9c21c3a Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 7 Jan 2022 13:35:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/http/OkHttpUtils.kt | 4 ++-- .../app/utils/{UTF8BOMFighter.kt => Utf8BomUtils.kt} | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) rename app/src/main/java/io/legado/app/utils/{UTF8BOMFighter.kt => Utf8BomUtils.kt} (85%) diff --git a/app/src/main/java/io/legado/app/help/http/OkHttpUtils.kt b/app/src/main/java/io/legado/app/help/http/OkHttpUtils.kt index c92d93945..c827c5bb3 100644 --- a/app/src/main/java/io/legado/app/help/http/OkHttpUtils.kt +++ b/app/src/main/java/io/legado/app/help/http/OkHttpUtils.kt @@ -4,7 +4,7 @@ import io.legado.app.constant.AppConst import io.legado.app.help.AppConfig import io.legado.app.utils.EncodingDetect import io.legado.app.utils.GSON -import io.legado.app.utils.UTF8BOMFighter +import io.legado.app.utils.Utf8BomUtils import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.suspendCancellableCoroutine import kotlinx.coroutines.withContext @@ -95,7 +95,7 @@ suspend fun Call.await(): Response = suspendCancellableCoroutine { block -> } fun ResponseBody.text(encode: String? = null): String { - val responseBytes = UTF8BOMFighter.removeUTF8BOM(bytes()) + val responseBytes = Utf8BomUtils.removeUTF8BOM(bytes()) var charsetName: String? = encode charsetName?.let { diff --git a/app/src/main/java/io/legado/app/utils/UTF8BOMFighter.kt b/app/src/main/java/io/legado/app/utils/Utf8BomUtils.kt similarity index 85% rename from app/src/main/java/io/legado/app/utils/UTF8BOMFighter.kt rename to app/src/main/java/io/legado/app/utils/Utf8BomUtils.kt index bf55d780e..73440b819 100644 --- a/app/src/main/java/io/legado/app/utils/UTF8BOMFighter.kt +++ b/app/src/main/java/io/legado/app/utils/Utf8BomUtils.kt @@ -1,15 +1,15 @@ package io.legado.app.utils @Suppress("unused") -object UTF8BOMFighter { +object Utf8BomUtils { private val UTF8_BOM_BYTES = byteArrayOf(0xEF.toByte(), 0xBB.toByte(), 0xBF.toByte()) fun removeUTF8BOM(xmlText: String): String { val bytes = xmlText.toByteArray() val containsBOM = (bytes.size > 3 - && bytes[0] == UTF8_BOM_BYTES[0] - && bytes[1] == UTF8_BOM_BYTES[1] - && bytes[2] == UTF8_BOM_BYTES[2]) + && bytes[0] == UTF8_BOM_BYTES[0] + && bytes[1] == UTF8_BOM_BYTES[1] + && bytes[2] == UTF8_BOM_BYTES[2]) if (containsBOM) { return String(bytes, 3, bytes.size - 3) }