English 中文(简体)
严格控制
原标题:String Encoding doesn t ouput all characters

My client uses InputStreamReader/BufferedReader to fetch text from the Internet. However when I save the Text to a *.txt the text shows extra weird special symbols like  .

  • 我曾尝试将“强力”转至ASCII,但我使用的是Syssupp å,ä,ö。

  • I ve tried food = food.replace("Â", ""); and IndexOf(); But string won t find it. But it s there in HEX Editor.

So summary: When I use text.setText(Android), the output looks fine with NO weird symbols, but when I save the text to *.txt I get about 4 of  . I do not want ASCII because I use other Non-ASCII character. The  is displayed as a Whitespace on my Android and in notepad.

感谢!

有一个伟大的周!

EDIT: Solved it by removing all Non-breaking-spaces:

myString.replaceAll("\u00a0"," ");
最佳回答

你说,你就是这样说的:

in = new BufferedReader(new InputStreamReader(url.openStream(),"UTF-8")); 

在UTF-8中,你手脚的 st子没有形成。

您需要打上HttpURLConnection物上的getContentType(),如果是非核心,则在你创建时提取编码并加以使用。 InputStreamReader。 只有“UTF-8”才假定,如果答复不提供带有有效编码的内容类型。


反之,尽管您对服务器退还的内容类型给予了关注,但真正的问题还是以你撰写文件的形式出现,或者以显示奇怪特征的显示工具出现。

  • It is not clear what encoding you are using to write the file. Perhaps you have chosen the wrong one.
  • It is possible that the display tool is assuming that the file has a different encoding. Maybe it detects that a file is UTF-8 or UTF-16 is there is a BOM.
  • It is possible that the display tool is plain broken, and doesn t understand non-breaking spaces.

当你使用一名联合执行编辑显示档案时,最有可能使用一种8倍的特性,这种特性很可能是拉丁-1。 但显然,档案实际上被不同编码。

不管怎么说,取代非突破性空间的方法是(海事组织)一个黑板,它战胜了你今后可能遇到的其它障碍。 因此,我建议你花时间真正理解这个问题,并适当解决这一问题。


最后,我认为,我理解你为什么会忘记天才。 A Unicode NON-BREASER-SPACE nature is u00a0. 当你以UTF-8为标志时,你获得C2 A0。 但拉丁美洲的C2是CAPITAL-A-CIRCUMFLEX,而拉丁美洲的A0是NON-BREA-SPACE。 因此,“汇合”很可能是贵方案在UTF-8中撰写了 *.txt文档,该工具将它视为拉丁-1。

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签