Easyclick read text garbled solution
This problem is caused by the forced reading of text encoded as UTF-8 after the upgrade of easyclick
for example,
terms of settlement
-
- write and read Java plug-ins in your own way. After modifying the encoding of the text to UTF-8, it can be read normally</ ol>
Java plug-in code
package com.plugin.gudcgukOhj;
import android.content.Context;
import android.os.Environment;
import android.util.Log;
import java.io.*;
import java.nio.charset.Charset;
public class PluginClz {
Context context;
public PluginClz(Context context) {
System.out.println("--- " + context);
}
/**
* Read the local text content to the specified encoding type
* @param strFilePath Full name of the text path
* @param encode encoding type
* @return
*/
public static String ReadTxtFile(String strFilePath ,String encode) {
String path = strFilePath;
String content = "";
//open
File file = new File(path);
if (!file.isDirectory()) {
try {
InputStream instream = new FileInputStream(file);
InputStreamReader inputStreamReader = null;
try {
inputStreamReader = new InputStreamReader(instream, encode);
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
BufferedReader reader = new BufferedReader(inputStreamReader);
StringBuffer sb = new StringBuffer("");
String line;
try {
while ((line = reader.readLine()) != null) {
sb.append(line);
sb.append("\n");
}
} catch (IOException e) {
e.printStackTrace();
}
content = sb.toString();
} catch (java.io.FileNotFoundException e) {
System.ou.println("TestFile", "The File doesn't not exist.");
}
}
return content;
}
}
Calling method main.js
//The call here is made by loading the apk file first and then instantiating the object
// the js file package will not enter the plug-in, for testing purposes only
function main() {
//this is where the plugin is loaded
var r = loadDex("mokuai.apk");
if (!r) {
loge("failed to load the plugin");
return;
} else {
logd("Loading the plugin was successful");
}
//Here the object is instantiated, and then the relevant method is called
var obj = new com.plugin.gudcgukOhj.PluginClz(context);
let file = "/sdcard/1.txt"
let encode = "GB18030"; // Specify your original encoding
var s = obj.ReadTxtFile(file,encode);
logd("java return data: "+s);
}
main();
Read More:
- [Go] Solve the garbled content sent by go-smtp and the unparsed html mail sent
- Sublime text 3 does not support Chinese/[decode error – output not UTF-8] solution
- How to Solve Cocos creator label text is too many error
- Sublime text4 install package error [How to Solve]
- [Solved] Cannot read properties of undefined (reading ‘ajax‘); Cannot read property ‘ajax‘ of undefined
- Oracle prompt text does not match format string
- Elasticsearch 6.2.3 version executes aggregation error Fielddata is disabled on text fields by default
- Kubernetes Error: Error in configuration: unable to read client-cert* unable to read client-key*
- GCC Error:(.text+0x24): undefined reference to `main‘collect2: error: ld returned 1 exit status [Solved]
- Opencv c++ Read Video Error: capture.isOpened() Return false
- Can’t read property ‘push’ of undefined [How to Solve]
- [Solved] Vue + uniapp Uncaught TypeError: Cannot read property ‘getters‘ of undefined
- [Solved] fatal: could not read Username for
- Cv2.dnn read model error [How to Solve]
- openlayers — Cannot read property ‘slice‘ of null—Map cannot be loaded
- [Solved] Echarts Error: Cannot read property ‘init‘ of undefined
- IDEA Error: clear read-only status [How to Solve]
- How to Solve Pydicom Read Dicom File Error: OSError
- [Solved] TensorFlow severing Container Creat Error: failed: Out of range: Read less bytes than requested