pull/1500/head
gedoor 3 years ago
parent f6a98d1439
commit 5c5845a1ba
  1. 8
      app/src/main/java/io/legado/app/model/localBook/TextFile.kt

@ -25,17 +25,17 @@ class TextFile(private val book: Book) {
LocalBook.getBookInputStream(book).use { bis ->
val buffer = ByteArray(BUFFER_SIZE)
var blockContent: String
bis.read(buffer)
var length = bis.read(buffer)
book.charset = EncodingDetect.getEncode(buffer)
charset = book.fileCharset()
blockContent = String(buffer, charset)
blockContent = String(buffer, 0, length, charset)
rulePattern = if (book.tocUrl.isNotEmpty()) {
Pattern.compile(book.tocUrl, Pattern.MULTILINE)
} else {
if (blockContent.isEmpty()) {
bis.read(buffer)
length = bis.read(buffer)
book.charset = EncodingDetect.getEncode(buffer)
blockContent = String(buffer, charset)
blockContent = String(buffer, 0, length, charset)
}
getTocRule(blockContent)?.let {
Pattern.compile(it.rule, Pattern.MULTILINE)

Loading…
Cancel
Save