How to remove unrecognized characters that are returned from a web service?

I am working on an application that calls a web service for recreation. Sometimes xml responses contain characters that cannot be displayed on the phone. When these characters are displayed, an empty field is displayed instead. I would like to filter out these characters. How to determine if a character can be displayed on the screen?

Some special characters include:

http://www.fileformat.info/info/unicode/char/0094/index.htm http://www.fileformat.info/info/unicode/char/0080/index.htm http: //www.fileformat. info / info / unicode / char / 0092 / index.htm

+3
source share
3

Android encodings

  • Xml.Encoding ISO_8859_1
  • Xml.Encoding US_ASCII
  • Xml.Encoding UTF_16
  • Xml.Encoding UTF_8

US_ASCII .

ISO_8859_1 wiki 0x00-0x1f 0x7f-0x9f . , , .

UTF_8 16 , Joels , Unicode

.

+5

, :

Charset.defaultCharset();

XML XML Content-Type HTTP-.
:

<?xml version="1.0" encoding="utf-8" ?>

Content-Type: text/html; charset=utf-8

XML, , :

new String( bytes);

, Dalvik .
:

new String( bytes, encoding);
+1

, Character.isIdentifierIgnorable() , . Character.isISOControl(), , .

0

Source: https://habr.com/ru/post/1741379/


All Articles