mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -10,6 +10,7 @@ import io.legado.app.utils.MD5Utils
|
||||
import io.legado.app.utils.StringUtils
|
||||
import io.legado.app.utils.Utf8BomUtils
|
||||
import java.io.FileNotFoundException
|
||||
import java.lang.IllegalArgumentException
|
||||
import java.nio.charset.Charset
|
||||
import java.util.regex.Matcher
|
||||
import java.util.regex.Pattern
|
||||
@@ -98,6 +99,7 @@ class TextFile(private val book: Book) {
|
||||
LocalBook.getBookInputStream(book).use { bis ->
|
||||
val buffer = ByteArray(bufferSize)
|
||||
val length = bis.read(buffer)
|
||||
if (length == -1) throw IllegalArgumentException("Unexpected Empty Txt File")
|
||||
if (book.charset.isNullOrBlank()) {
|
||||
book.charset = EncodingDetect.getEncode(buffer.copyOf(length))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user