これが私のWebサービスの応答です..
Testperson-se、承認済み、Stårgatan 1,12345、Ankeborg、SE
Stårgatanのこの文字列には、ドット付きの特殊文字aがあり、この応答を印刷すると..のような疑問符文字列が表示されます.
Testperson-se、承認済み、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 "";
}
}
この特殊文字を印刷するには?