[英]Converting UTF-8 encoded with Latin-1 codepage to iso-8859-1 bytes
It's been a long day. 这是漫长的一天。 I'm not sure if I'm overlooking something, or if there isn't an easy answer to my problem. 我不确定我是在俯视什么,还是没有简单的答案可以解决我的问题。
Here's my Scenario: 这是我的方案:
In my attempts to re-encode these Strings, I end up with either '?' 在尝试对这些字符串进行重新编码时,我最终都以“?”结尾 replacements for the foreign characters, the 2nd Unicode Byte, or both Unicode bytes being sent. 替换外来字符,第二个Unicode字节或发送两个Unicode字节。
Is there a simple way to take this incoming data that uses 2 bytes to describe these Latin-1 code page characters and encode them as ISO-8859-1 Bytes? 是否有一种简单的方法来获取使用2个字节描述这些Latin-1代码页字符并将其编码为ISO-8859-1字节的传入数据?
On the reader side you need something like: 在读者方面,您需要以下内容:
new InputStreamReader(underlyingInputStream, "UTF-8")
On the writer side: 在作者方面:
new OutputStreamWriter(underlyingOutputStream, "ISO-8859-1")
Then you should be able to read the incoming UTF-8 encoded characters, and write them as ISO-8859-1 encoded characters. 然后,您应该能够读取传入的UTF-8编码字符,并将其写为ISO-8859-1编码字符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.