Fix subtitle charset detect
This commit is contained in:
parent
5d59f778a7
commit
945e6326ce
|
|
@ -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'
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
12256c49c78305f2bedfd09b5d786620
|
||||
16f9147da64cbbc596831e87ebcafd79
|
||||
|
|
|
|||
Loading…
Reference in New Issue