如何从Web服务中删除无法识别的字符? [英] How do I remove unrecognized characters which come back from a web service?

查看:190
本文介绍了如何从Web服务中删除无法识别的字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个调用休息Web服务的应用程序。有时,xml响应包含手机无法显示的字符。显示这些字符时,会显示一个空白框。我想过滤掉这些字符。如何检测人物是否能够在屏幕上显示?



某些特定字符包括:



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

解决方案

Android支持以下编码




  • Xml.Encoding ISO_8859_1

  • Xml.Encoding US_ASCII

  • Xml.Encoding UTF_16

  • Xml.Encoding UT F_8



US_ASCII不应该有任何问题。



对于ISO_8859_1你请检查 http://en.wikipedia.org/wiki/ISO/IEC_8859-1
用于控制字符0x00-0x1f和0x7f-0x9f并进行过滤。
当然使用匹配的字体。



使用UTF_8或16更复杂,请阅读Joels 绝对最小的每个软件开发人员绝对必须了解Unicode和字符集



你可能会发现这个邮件的列表有用。


I am working on an app which calls a rest web service. Sometimes the xml responses contain characters which the phone can not display. When displaying these characters, an empty box is displayed instead. I would like to filter out these characters. How can I detect if a character will be able to be displayed on the screen?

Some specific 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

解决方案

Android support the following encodings

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

US_ASCII shouldn't make any problems.

For ISO_8859_1 you sould check http://en.wikipedia.org/wiki/ISO/IEC_8859-1 for control chars 0x00-0x1f and 0x7f-0x9f and filter them. And of course use a matching font.

Using UTF_8 or 16 is more complex, read Joels The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets

You might find this mailing list useful.

这篇关于如何从Web服务中删除无法识别的字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆