How to add diffrent characterset support for Jtext

2019-05-18 19:30发布

I need to display a document, which is in Cp037 character Encoding, in JTextArea? I think JTextArea by default supports UNICODE character encoding. How to add Cp037 charater set support to JTextArea?

2条回答
Summer. ? 凉城
2楼-- · 2019-05-18 20:15

JTextArea only support Java char, which uses UTF-16BE encoding. If you have some byte-stream in CP037, you need to convert it to String or Char array first.

For example, if you have characters in Cp037 as a byte array, you should do this,

  String text = new String(bytes, "Cp037");

You may need to install extra charset support for certain JREs.

查看更多
走好不送
3楼-- · 2019-05-18 20:26

Doesn't JTextArea use UTF-8 for output? Important if you generate code you want to use in eclipse. Got some problems with § over there.

查看更多
登录 后发表回答