给js引擎增加java.utf8ToGbk编码转换

pull/277/head
10bits 4 years ago committed by GitHub
parent b715b6f4fe
commit 35f0a66090
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      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")))
}
}

Loading…
Cancel
Save