Windows-1251到UTF-8代码 [英] Windows-1251 to UTF-8 codes

查看:186
本文介绍了Windows-1251到UTF-8代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows-1251代码表中有代码字符。
我怎么能得到这个字符的代码在UTF-8代码表中?

I have code of character in Windows-1251 code table. How i can get code of this character in UTF-8 code table?

例如我有字符'А'在Windows- ,适当的utf-8代码等于1040

For example i have character 'А' with coded in Windows-1251 equals 192, appropriate utf-8 code equals 1040

我如何可以用Windows-1251代码表的代码192初始化Java或字符?

How i can to initialize Character or char in Java with code 192 from Windows-1251 code table?

char c =(char)192; //如何指定编码?

char c = (char)192; //how to specify the encoding ?

推荐答案

要将一个字符编码的byte []编码转换为另一个, / p>

To convert a byte[] encoding in one character encoding to another you can do

public static byte[] convertEncoding(byte[] bytes, String from, String to) {
    return new String(bytes, from).getBytes(to);
}

这篇关于Windows-1251到UTF-8代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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