diff --git a/app/build.gradle b/app/build.gradle index fa80f51f..720c35c2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -38,6 +38,7 @@ dependencies { //Debug For HTTP/3 debugImplementation 'org.chromium.net:cronet-embedded:101.4951.41' implementation('com.github.thegrizzlylabs:sardine-android:0.8') { exclude group: 'com.squareup.okhttp3', module: 'okhttp' } + implementation 'com.googlecode.juniversalchardet:juniversalchardet:1.0.3' implementation('com.squareup.okhttp3:okhttp:3.12.13') { force = true } implementation 'com.google.net.cronet:cronet-okhttp:0.1.0' implementation 'com.google.code.gson:gson:2.8.6' diff --git a/app/src/main/java/com/github/catvod/utils/Utils.java b/app/src/main/java/com/github/catvod/utils/Utils.java index 7ab81bc2..ce8a45c5 100644 --- a/app/src/main/java/com/github/catvod/utils/Utils.java +++ b/app/src/main/java/com/github/catvod/utils/Utils.java @@ -13,8 +13,9 @@ import android.webkit.WebViewClient; import com.github.catvod.spider.Init; +import org.mozilla.universalchardet.UniversalDetector; + import java.math.BigInteger; -import java.nio.charset.Charset; import java.security.MessageDigest; import java.util.Arrays; import java.util.List; @@ -49,15 +50,11 @@ public class Utils { return hasCamera && hasPhone && hasBT; } - public static boolean isGbk(byte[] bytes) { - Charset charset = Charset.forName("GBK"); - String str = new String(bytes, charset); - byte[] newBytes = str.getBytes(charset); - return Arrays.equals(bytes, newBytes); - } - public static byte[] toUtf8(byte[] bytes) throws Exception { - return isGbk(bytes) ? new String(bytes, Charset.forName("GBK")).getBytes("UTF-8") : bytes; + UniversalDetector detector = new UniversalDetector(null); + detector.handleData(bytes, 0, bytes.length); + detector.dataEnd(); + return new String(bytes, detector.getDetectedCharset()).getBytes("UTF-8"); } public static boolean isSub(String ext) { diff --git a/jar/custom_spider.jar b/jar/custom_spider.jar index a5646226..6df099e6 100644 Binary files a/jar/custom_spider.jar and b/jar/custom_spider.jar differ diff --git a/jar/custom_spider.jar.md5 b/jar/custom_spider.jar.md5 index 2c3df245..27df9a04 100644 --- a/jar/custom_spider.jar.md5 +++ b/jar/custom_spider.jar.md5 @@ -1 +1 @@ -12256c49c78305f2bedfd09b5d786620 +16f9147da64cbbc596831e87ebcafd79