diff --git a/app/src/main/java/io/legado/app/help/http/EncodeConverter.kt b/app/src/main/java/io/legado/app/help/http/EncodeConverter.kt index b27d0a210..0cad990f0 100644 --- a/app/src/main/java/io/legado/app/help/http/EncodeConverter.kt +++ b/app/src/main/java/io/legado/app/help/http/EncodeConverter.kt @@ -17,20 +17,22 @@ class EncodeConverter(private val encode: String? = null) : Converter.Factory() ): Converter? { return Converter { value -> val responseBytes = UTF8BOMFighter.removeUTF8BOM(value.bytes()) - encode?.let { return@Converter String(responseBytes, Charset.forName(encode)) } + var charsetName: String? = encode - var charsetName: String? = null - val mediaType = value.contentType() - //根据http头判断 - if (mediaType != null) { - val charset = mediaType.charset() - charsetName = charset?.displayName() + charsetName?.let { + try { + return@Converter String(responseBytes, Charset.forName(charsetName)) + } catch (e: Exception) { + } } - if (charsetName == null) { - charsetName = EncodingDetect.getHtmlEncode(responseBytes) + //根据http头判断 + value.contentType()?.charset()?.let { + return@Converter String(responseBytes, it) } + //根据内容判断 + charsetName = EncodingDetect.getHtmlEncode(responseBytes) String(responseBytes, Charset.forName(charsetName)) } } diff --git a/app/src/main/res/color/selector_image.xml b/app/src/main/res/color/selector_image.xml new file mode 100644 index 000000000..60fb16ed2 --- /dev/null +++ b/app/src/main/res/color/selector_image.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file