修复txt的一些问题

pull/1649/head
kunfei 3 years ago
parent a0d181a90b
commit 0e8a669c86
  1. 6
      app/src/main/java/io/legado/app/model/localBook/TextFile.kt

@ -57,12 +57,14 @@ class TextFile(private val book: Book) {
*/ */
@Throws(FileNotFoundException::class) @Throws(FileNotFoundException::class)
fun getChapterList(): ArrayList<BookChapter> { fun getChapterList(): ArrayList<BookChapter> {
if (book.charset == null || book.tocUrl.isEmpty()) { if (book.charset == null || book.tocUrl.isBlank()) {
LocalBook.getBookInputStream(book).use { bis -> LocalBook.getBookInputStream(book).use { bis ->
val buffer = ByteArray(bufferSize) val buffer = ByteArray(bufferSize)
var blockContent: String var blockContent: String
var length = bis.read(buffer) var length = bis.read(buffer)
book.charset = EncodingDetect.getEncode(buffer) if (book.charset.isNullOrBlank()) {
book.charset = EncodingDetect.getEncode(buffer)
}
charset = book.fileCharset() charset = book.fileCharset()
blockContent = String(buffer, 0, length, charset) blockContent = String(buffer, 0, length, charset)
if (book.tocUrl.isBlank()) { if (book.tocUrl.isBlank()) {

Loading…
Cancel
Save