如何添加不同的字符集支持JtextArea? [英] How to add diffrent characterset support for JtextArea?

查看:154
本文介绍了如何添加不同的字符集支持JtextArea?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要显示一个文件,这是在Cp037字符编码,在JTextArea?我认为JTextArea默认支持UNICODE字符编码。如何添加Cp037字符集支持 JTextArea

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?

推荐答案

支持Java char,它使用UTF-16BE编码。

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.

例如,如果您在Cp037中有字符串作为字节数组,你应该这样做:

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

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

您可能需要为某些JRE安装额外的字符集支持。

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

这篇关于如何添加不同的字符集支持JtextArea?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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