From 100218060efe8a293c5f176d996ef94e42071154 Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 7 Jan 2022 10:46:48 +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 --- .../main/java/io/legado/app/utils/UTF8BOMFighter.kt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/utils/UTF8BOMFighter.kt b/app/src/main/java/io/legado/app/utils/UTF8BOMFighter.kt index 3f502f8b6..bf55d780e 100644 --- a/app/src/main/java/io/legado/app/utils/UTF8BOMFighter.kt +++ b/app/src/main/java/io/legado/app/utils/UTF8BOMFighter.kt @@ -18,9 +18,9 @@ object UTF8BOMFighter { fun removeUTF8BOM(bytes: ByteArray): ByteArray { 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) { val copy = ByteArray(bytes.size - 3) System.arraycopy(bytes, 3, copy, 0, bytes.size - 3) @@ -28,4 +28,11 @@ object UTF8BOMFighter { } return bytes } + + fun hasBom(bytes: ByteArray): Boolean { + return (bytes.size > 3 + && bytes[0] == UTF8_BOM_BYTES[0] + && bytes[1] == UTF8_BOM_BYTES[1] + && bytes[2] == UTF8_BOM_BYTES[2]) + } } \ No newline at end of file