Android 下载的非英语html文件在webview中不可读
保存(malayalam)字符串内容代码Android 下载的非英语html文件在webview中不可读,android,character-encoding,webview,download,utf-32,Android,Character Encoding,Webview,Download,Utf 32,保存(malayalam)字符串内容代码 String A = "<html><head><style>" + "@font-face { font-family: Manorama;src: url(file:///android_asset/Manorama.ttf); }" + "h1 { color: #222;font-size: 26px;margin-top: 32px; }"
String A = "<html><head><style>"
+ "@font-face { font-family: Manorama;src: url(file:///android_asset/Manorama.ttf); }"
+ "h1 { color: #222;font-size: 26px;margin-top: 32px; }"
+ "</style></head><body><h1>"
+ "<font face=\"Manorama\">ØíxàW ¥çÄÞùßxßÏßW 190 æd¿ÏßÈß</font><!--3546062932-->"
+ "</p><body></html>";
FileOutputStream OStream = null;
try {
OStream = openFileOutput("0.html", Context.MODE_PRIVATE);
OStream.write(A.getBytes("UTF-32"));
OStream.close();
} catch (Exception e) {
}
String A=“”
+“@font-face{font-family:Manorama;src:url(file:///android_asset/Manorama.ttf); }"
+“h1{颜色:#222;字体大小:26px;页边空白顶部:32px;}”
+ ""
+“你的名字是什么?”
+“”;
FileOutputStream OStream=null;
试一试{
OStream=openFileOutput(“0.html”,Context.MODE\u PRIVATE);
OStream.write(A.getBytes(“UTF-32”);
OStream.close();
}捕获(例外e){
}
它工作得很好,但当我从服务器下载后执行相同的操作时,它不起作用(在webview中字符是不可读的),
找到下面的代码
HttpClient client = new DefaultHttpClient();
HttpResponse response = null;
InputStream in = null;
try {
response = client.execute(new HttpGet(
"http://tinymail.in/mail_pipe/thozhilveedhi/pull"));
in = response.getEntity().getContent();
} catch (Exception e) {
}
BufferedReader reader = new BufferedReader(
new InputStreamReader(in));
StringBuilder string = new StringBuilder();
String line = null;
try {
while ((line = reader.readLine()) != null) {
string.append(line);
}
in.close();
} catch (Exception e) {
}
String[] A = (string.toString()).split("__");
for (int i = 0; i < A.length; i++) {
if (A[i] != "") {
try {
FileOutputStream OStream = openFileOutput(i + ".html",
Context.MODE_PRIVATE);
OStream.write(A[i].getBytes("UTF-32"));
OStream.close();
} catch (Exception e) {
}
}
}
HttpClient=newdefaulthttpclient();
HttpResponse响应=null;
InputStream in=null;
试一试{
response=client.execute(新的HttpGet(
"http://tinymail.in/mail_pipe/thozhilveedhi/pull"));
in=response.getEntity().getContent();
}捕获(例外e){
}
BufferedReader reader=新的BufferedReader(
新的InputStreamReader(in);
StringBuilder字符串=新的StringBuilder();
字符串行=null;
试一试{
而((line=reader.readLine())!=null){
追加(行);
}
in.close();
}捕获(例外e){
}
String[]A=(String.toString()).split(“_u”);
for(int i=0;i
我认为问题在于从服务器到android的数据传输,我能做什么??Base64传输编码解决了这个问题吗??
请帮忙
HttpClient client = new DefaultHttpClient();
HttpResponse response = null;
try {
response = client.execute(new HttpGet(
"http://tinymail.in/mail_pipe/thozhilveedhi/pull"));
} catch (Exception e) {
}
HttpEntity entity = response.getEntity();
if (entity != null) {
String data = EntityUtils.toString(entity);
String[] A = null;
..读取文件&保存下面的代码
try {
FileOutputStream OStream = openFileOutput(i
+ ".html", Context.MODE_PRIVATE);
OStream.write(A[i].getBytes("UTF-16"));
OStream.close();
} catch (Exception e) {
}
}
}
}
write(A[i].getBytes(“ISO-8859-1”);