pull/83/head
parent
a388f9eb9b
commit
a64bf91749
@ -0,0 +1,21 @@ |
|||||||
|
package io.legado.app.model.localbook |
||||||
|
|
||||||
|
import android.content.Context |
||||||
|
import android.net.Uri |
||||||
|
import io.legado.app.data.entities.Book |
||||||
|
import io.legado.app.utils.EncodingDetect |
||||||
|
|
||||||
|
object AnalyzeTxtFile { |
||||||
|
|
||||||
|
|
||||||
|
fun analyze(context: Context, book: Book) { |
||||||
|
context.contentResolver.openInputStream(Uri.parse(book.bookUrl))?.use { stream -> |
||||||
|
val rawByteArray = ByteArray(2000) |
||||||
|
stream.read(rawByteArray) |
||||||
|
book.charset = EncodingDetect.getJavaEncode(rawByteArray) |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue