Merge pull request #277 from 10bits/master

给js引擎增加java.utf8ToGbk编码转换
pull/276/head^2
kunfei 4 years ago committed by GitHub
commit 998d8d216e
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