|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
发信人: cloudor (String[] args), 信区: Java
标 题: Re: 请教字符编码问题
发信站: BBS 水木清华站 (Tue Oct 15 11:39:46 2002), 站内信件
【 在 cloudor (String[] args) 的大作中提到: 】
: 不对!这不是UTF!!
: 这只是普通的gb.
编了个程序证明我所说的.
先把"3130D4C23134C8D5"字符串保存成字节,再用gb18030,gb2312,gbk,
big5,utf-8,utf-16以及一个根本不存在的blabla等charset来decode.
结果为:
---------
10月14日
10月14日
10月14日
10?14??
10??14??
????
Not supported encode:blabla
---------
我的程序为:
- //: TestEnc.java
- public class TestEnc
- {
- public static void main(String args[])
- {
- /* ========================================
- convert and display
- ======================================== */
- int size = (s.length()/2);
- byte[] b=new byte[size];
- for(int i=0;i<size;i++)
- b[i]=(byte)Integer.parseInt(s.substring(i*2,i*2+2),16);
- for(int i=0;i<encode.length;i++)
- {
- try
- {
- System.out.println( new String(b,encode[i]) );
- }catch(Exception e)
- {
- System.out.println("Not supported encode:"+encode[i]);
- }
- }
- }
- }
- ///:~
复制代码
--
上上下下浇着那条毛巾,然后,我打了个冷战.
※ 来源:·BBS 水木清华站 smth.edu.cn·[FROM: 218.18.24.9] |
|