Android UTF-8编码引号
Android UTF-8 Encoding quotation marks
在我的 Android 应用程序中,我使用 utf-8 字符集从服务器获取 JSON 数据。我正在使用以下代码对来自服务器的数据进行编码:
try {
HttpResponse execute = client.execute(httpGet);
InputStream content = execute.getEntity().getContent();
BufferedReader buffer = new BufferedReader(
new InputStreamReader(content, "utf-8"));
String s = "";
while ((s = buffer.readLine()) != null) {
response += s;
}
return response;
在我的应用程序中,我可以看到所有特殊字符,如 ä、ü 等,但没有显示 "(引号)。在 Android 5.0 以下,有 space,在Android 5.0,是一个盒子而不是角色(如图所示)。
如何使用 Unicode "\u0084" 和 "\u0093" 显示引号?
这是来自 Android 5.0 (Api 21) 的屏幕截图
这是 Android 4.3 中的一个:
那些\u0093
和\u0084
真的是控制字符。他们不一定有实际代表。
相反,您应该使用 \u201C
和 \u201D
见:
http://www.fileformat.info/info/unicode/char/201C/index.htm and http://www.fileformat.info/info/unicode/category/Pi/list.htm
在我的 Android 应用程序中,我使用 utf-8 字符集从服务器获取 JSON 数据。我正在使用以下代码对来自服务器的数据进行编码:
try {
HttpResponse execute = client.execute(httpGet);
InputStream content = execute.getEntity().getContent();
BufferedReader buffer = new BufferedReader(
new InputStreamReader(content, "utf-8"));
String s = "";
while ((s = buffer.readLine()) != null) {
response += s;
}
return response;
在我的应用程序中,我可以看到所有特殊字符,如 ä、ü 等,但没有显示 "(引号)。在 Android 5.0 以下,有 space,在Android 5.0,是一个盒子而不是角色(如图所示)。 如何使用 Unicode "\u0084" 和 "\u0093" 显示引号?
这是来自 Android 5.0 (Api 21) 的屏幕截图
这是 Android 4.3 中的一个:
那些\u0093
和\u0084
真的是控制字符。他们不一定有实际代表。
相反,您应该使用 \u201C
和 \u201D
见: http://www.fileformat.info/info/unicode/char/201C/index.htm and http://www.fileformat.info/info/unicode/category/Pi/list.htm