Answer the question
In order to leave comments, you need to log in
Response from server in encoding (u043a\u0430\u043a-\u0442\) how to decode?
I make a request like this:
HttpURLConnection urlConnection = null;
try {
urlConnection = (HttpURLConnection) new URL(urlConn).openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.setUseCaches(false);
urlConnection.connect();
BufferedReader input = new BufferedReader(new InputStreamReader(urlConnection.getInputStream(), "UNICODE"));
String line;
while ((line = input.readLine()) != null){
sb.append(line);
sb.append("\n");
}
Answer the question
In order to leave comments, you need to log in
If you use https://www.online-toolz.com/tools/text-unicode-en... you can see that the data is "how-to"
Another point - new InputStreamReader(urlConnection.getInputStream(), "UNICODE") - InputStreamReader does not know such encoding as "UNICODE"
If you open the dock for this class, you can see that the correct charset value will be - "UTF-8"
PS: surprisingly, it didn't work. Helps
BufferedReader input = new BufferedReader(new InputStreamReader(urlConnection.getInputStream(), StandardCharsets.UTF_8));
+
sb.append(StringEscapeUtils.unescapeJava(line));
Try to set the encoding for the string
line=new String(line = input.readLine(), StandardCharsets.UTF_8)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question