我正在编写Android并处理来自地址的请求 “http://www.mytvnet.vn/module/ajax/ajax_get_schedule.php?channelId=100&dateSchedule=18%2F01%2F2014”
请求的结果是
"
06:00<\/strong> Ch\u00e0o bu\u1ed5i s\u00e1ng<\/p>
06:30<\/strong> Ng\u00e0y m\u1edbi<\/p>
06:50<\/strong> B\u1ea3n tin Th\u1ecb tr\u01b0\u1eddng<\/p>
07:00<\/strong> Vi\u1ec7t Nam m\u1ebfn y\u00eau : Kh\u00e1m ph\u00e1 Tr\u00e0ng An<\/p>
07:20<\/strong> Qu\u00e0 t\u1eb7ng cu\u1ed9c s\u1ed1ng<\/p>
07:30<\/strong> T\u00ecnh kh\u00fac v\u01b0\u1ee3t th\u1eddi gian<\/p>
08:00<\/strong> Y h\u1ecdc ph\u01b0\u01a1ng \u0110\u00f4ng : \u0110i\u1ec1u tr\u1ecb b\u1ec7nh \u0111au d\u00e2y th\u1ea7n kinh t\u1ecda<\/p>
08:30<\/strong> Kh\u00e1m ph\u00e1 : Xanh bi\u1ebfc r\u1eebng Tr\u00e0m<\/p>
08:50<\/strong> S\u1ed1ng kh\u1ecfe : Ph\u00f2ng ch\u1ed1ng b\u1ec7nh b\u00e9o ph\u00ec<\/p>
09:10<\/strong> Chuy\u1ec7n \u0111\u00e0n \u00f4ng : L\u1ea5y v\u1ee3 mu\u1ed9n<\/p>
09:30<\/strong> Vi\u1ec7t nam \u2013 \u0111\u1ea5t n\u01b0\u1edbc, con ng\u01b0\u1eddi : Th\u1ecb x\u00e3 b\u00ean s\u00f4ng B\u00e9<\/p>
10:00<\/strong> Phim truy\u1ec7n : H\u1ea1nh ph\u00fac mu\u1ed9n m\u00e0ng - t\u1eadp 31<\/p>
11:00<\/strong> V\u0103n ngh\u1ec7 thi\u1ebfu nhi : Ti\u1ebfng chim l\u00edu lo<\/p>
11:15<\/strong> Ti\u1ebfng n\u00f3i c\u1eed tri<\/p>
11:30<\/strong> Th\u1eddi s\u1ef1 VTV Ph\u00fa Y\u00ean<\/p>
11:45<\/strong> Th\u1ecb tr\u01b0\u1eddng cu\u1ed1i tu\u1ea7n<\/p>
11:50<\/strong> Phim truy\u1ec7n : M\u1eaft b\u01b0\u1edbm - t\u1eadp 28<\/p>
12:50<\/strong> K\u00fd \u1ee9c mi\u1ec1n T\u00e2y : D\u1eeba \u01a1i ta nh\u1edb!<\/p>
13:00<\/strong> Kh\u00e1m ph\u00e1 Vi\u1ec7t Nam : Ba su\u1ed1i c\u00e1 Th\u1ea7n<\/p>
13:10<\/strong> B\u1ebfp Vi\u1ec7t : V\u1ecbt n\u01b0\u1edbng l\u00e1 l\u1ed1t<\/p>
13:40<\/strong> Ph\u00f3ng s\u1ef1 : M\u1ed9t ch\u1ee7 tr\u01b0\u01a1ng h\u1ee3p l\u00f2ng d\u00e2n<\/p>
14:00<\/strong> \u00c2m nh\u1ea1c v\u00e0 B\u01b0\u1edbc nh\u1ea3y<\/p>
14:30<\/strong> Nh\u1eefng m\u1ea3nh gh\u00e9p cu\u1ed9c s\u1ed1ng : Nh\u1eefng th\u01b0\u01a1ng c\u1ea3ng trong l\u1ecbch s\u1eed Vi\u1ec7t Nam - ph\u1ea7n 8<\/p>
15:00<\/strong> Phim truy\u1ec7n : C\u00e1 r\u00f4, em y\u00eau em - t\u1eadp 13<\/p>
16:00<\/strong> V\u0103n ngh\u1ec7 thi\u1ebfu nhi : Gi\u1ea5c m\u01a1 c\u1ed5 t\u00edch<\/p>
16:25<\/strong> Qu\u00e0 t\u1eb7ng cu\u1ed9c s\u1ed1ng<\/p>
16:30<\/strong> Phim t\u00e0i li\u1ec7u : H\u1ed9i An \u2013 \u0111\u1ea5t v\u00e0 ng\u01b0\u1eddi<\/p>
17:00<\/strong> Phim truy\u1ec7n : C\u1ed5 t\u00edch chuy\u1ec7n t\u00ecnh - t\u1eadp 28<\/p>
18:00<\/strong> \u0110i\u1ec3m h\u1eb9n x\u1ee9 Tr\u1ea7m H\u01b0\u01a1ng<\/p>
18:20<\/strong> Th\u1ebf gi\u1edbi th\u1ec3 thao<\/p>
18:30<\/strong> Th\u1eddi s\u1ef1 VTV Ph\u00fa Y\u00ean<\/p>
19:00<\/strong> Th\u1eddi s\u1ef1 TH Vi\u1ec7t Nam<\/p>
19:45<\/strong> Caf\u00e9 C\u01b0\u1eddi<\/p>
19:55<\/strong> Phim truy\u1ec7n : \u0110\u1ed9i \u0111\u1eb7c nhi\u1ec7m Hoa M\u1ed9c Lan \u2013 t\u1eadp 17<\/p>
20:45<\/strong> Ph\u00f3ng s\u1ef1 : T\u1ebft h\u01b0\u1edbng v\u1ec1 Tr\u01b0\u1eddng Sa<\/p>
21:00<\/strong> Phim truy\u1ec7n : \u0110\u1ea1i chi\u1ebfn c\u1ed5 kim - t\u1eadp 36<\/p>
21:45<\/strong> Tin t\u1ee9c<\/p>
21:50<\/strong> Phim truy\u1ec7n : Cu\u1ed9c chi\u1ebfn c\u00e1c b\u00e0 v\u1ee3 - t\u1eadp 17<\/p>
22:50<\/strong> Qu\u00e0 t\u1eb7ng cu\u1ed9c s\u1ed1ng<\/p>
23:00<\/strong> Th\u1ebf gi\u1edbi c\u1eadp nh\u1eadt<\/p>
23:20<\/strong> Th\u1ebf gi\u1edbi th\u1ec3 thao<\/p>
23:30<\/strong> T\u00ecnh kh\u00fac v\u01b0\u1ee3t th\u1eddi gian : Mong l\u00e0 gi\u1ea5c m\u01a1<\/p>"
当我从我的代码中读取内容时:
String html = "";
InputStream in = response.getEntity().getContent();
BufferedReader reader = new BufferedReader(
new InputStreamReader(in));
StringBuilder str = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
str.append(line);
}
in.close();
html = str.toString();
TextView中的html显示仍然是“Ch\u00e0o bu\u1ed5i s\u00e1ng
”
我期望的结果是“Chào buổi sáng
”。我无法解决这个问题。
另一方面,如果我创建一个String
String test = "Ch\u00e0o bu\u1ed5i s\u00e1ng";
textView.setText(test);
然后结果将是Chào buổi sáng
。
我被困住了:(
答案 0 :(得分:0)
new InputStreamReader(is, "encoding")
答案 1 :(得分:0)
您可以尝试下面的代码。结果将显示您编写的代码无效的原因。
$ wget -qO- https://get.docker.io/ | sh
Error: you are not using a 64bit platform.
Docker currently only supports 64bit platforms.
也许您的代码应该如下:
public static void main(String[] argv) {
String test = "Ch\u00e0o bu\u1ed5i s\u00e1ng";
System.out.println(unicode2String(test));
}
/**
* unicode 转字符串
*/
public static String unicode2String(String unicode) {
StringBuffer string = new StringBuffer();
String[] hex = unicode.split("\\\\u");
string.append(hex[0]);
for (int i = 1; i < hex.length; i++) {
// 转换出每一个代码点
int data = Integer.parseInt(hex[i], 16);
// 追加成string
string.append((char) data);
}
return string.toString();
}