这是我的网络服务响应..
Testperson-se,已批准,Stårgatan 1,12345,Ankeborg,SE
现在在 Stårgatan 的这个字符串中,当我打印这个响应时,有一个带点的特殊字符 a,它给了我问号字符串,比如 ..
Testperson-se,Approved,St?rgatan 1,12345,Ankeborg,SE
我使用以下代码。
try {
URL url = new URL(
"http://www.ecodor.se/administrator/components/com_ivmstore/ivmwebservices/getaddress.php?pNumber=410321-9202"
);//
InputSource is = new InputSource(url.openStream());
StringBuffer res = new StringBuffer();
res.append(convertStreamToString(is.getByteStream()));
line = res.toString();
Log.i("==> responce", line);
//
} catch (Exception e) {
}
public String convertStreamToString(InputStream is) throws IOException {
/*
* To convert the InputStream to String we use the
* BufferedReader.readLine() method. We iterate until the BufferedReader
* return null which means there's no more data to read. Each line will
* appended to a StringBuilder and returned as String.
*/
if (is != null) {
StringBuilder sb = new StringBuilder();
String line;
try {
BufferedReader reader = new BufferedReader(
new InputStreamReader(is, "UTF-8"));
while ((line = reader.readLine()) != null) {
sb.append(line).append("\n");
}
} finally {
is.close();
}
return sb.toString();
} else {
return "";
}
}
如何打印这个特殊字符?