开发者

How to encode character in Microsoft Windows Codepage 1251 (Cyrl) in java

I want to encode string in Java with Microsoft Windows Codepage 1251 (Cy开发者_运维问答rl) table.


You don't have to "encode" a string. When you turn a string from/to bytes you need to decode/encode them. So you actually encode a binary array.

byte[] cp1251encodedBytes = "your characters".getBytes(Charset.forName("Cp1251"));

List of supported encodings: http://download.oracle.com/javase/1.4.2/docs/guide/intl/encoding.doc.html

Update: updated to Charset.forName() as McDowell commented.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜