diff --git a/app/src/main/java/io/legado/app/help/JsExtensions.kt b/app/src/main/java/io/legado/app/help/JsExtensions.kt index a58fd7ce6..d12fc07ea 100644 --- a/app/src/main/java/io/legado/app/help/JsExtensions.kt +++ b/app/src/main/java/io/legado/app/help/JsExtensions.kt @@ -52,4 +52,10 @@ interface JsExtensions { fun timeFormat(time: Long): String { return dateFormat.format(Date(time)) } + //utf8编码转gbk编码 + fun utf8ToGbk(str: String): String { + val utf8 = String(str.toByteArray(charset("UTF-8"))) + val unicode = String(utf8.toByteArray(), charset("UTF-8")) + return String(unicode.toByteArray(charset("GBK"))) + } }