修复txt的一些问题
This commit is contained in:
@@ -60,18 +60,13 @@ class TextFile(private val book: Book) {
|
|||||||
if (book.charset == null || book.tocUrl.isBlank()) {
|
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
|
val length = bis.read(buffer)
|
||||||
var length = bis.read(buffer)
|
|
||||||
if (book.charset.isNullOrBlank()) {
|
if (book.charset.isNullOrBlank()) {
|
||||||
book.charset = EncodingDetect.getEncode(buffer.copyOf(length))
|
book.charset = EncodingDetect.getEncode(buffer.copyOf(length))
|
||||||
}
|
}
|
||||||
charset = book.fileCharset()
|
charset = book.fileCharset()
|
||||||
blockContent = String(buffer, 0, length, charset)
|
|
||||||
if (book.tocUrl.isBlank()) {
|
if (book.tocUrl.isBlank()) {
|
||||||
if (blockContent.isEmpty()) {
|
val blockContent = String(buffer, 0, length, charset)
|
||||||
length = bis.read(buffer)
|
|
||||||
blockContent = String(buffer, 0, length, charset)
|
|
||||||
}
|
|
||||||
book.tocUrl = getTocRule(blockContent)?.pattern() ?: ""
|
book.tocUrl = getTocRule(blockContent)?.pattern() ?: ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user