国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

常用的編碼格式

2019-11-14 15:23:24
字體:
來源:轉載
供稿:網友

eclipse常用的編碼格式有:US-ASCII、UTF-16、UTF-8、GBK等。

貼個講的相當好的鏈接:http://www.qianxingzhem.com/post-1499.html

public class javatest {    public static void main(String[] args) throws Exception{        String s = "太陽ABC";        /*         * 因為eclipse默認的編碼是GBK,所以byte1和byte2輸出完全一樣         * GBK編碼是英文用一個字節表示,漢字用兩個字節         */        byte[] byte1 = s.getBytes();        for (byte b : byte1) {            System.out.PRint(Integer.toHexString(b & 0Xff) + " ");        }        System.out.println();        byte[] byte2 = s.getBytes("GBK");        for (byte b : byte2) {            System.out.print(Integer.toHexString(b & 0Xff) + " ");        }        System.out.println();        /*         * ASCII碼的表示方法,并不會將漢字表示出來         */        byte[] byte3 = s.getBytes("US-ASCII");        for (byte b : byte3) {            System.out.print(Integer.toHexString(b & 0Xff) + " ");        }        System.out.println();        /*         * UTF-16三個字節表示漢字,兩個字節表示字母         */        byte[] byte4 = s.getBytes("UTF-16");        for (byte b : byte4) {            System.out.print(Integer.toHexString(b & 0Xff) + " ");        }        System.out.println();        /*         * UTF-16LE中兩個字節表示漢字,兩個字節表示字母         */        byte[] byte5 = s.getBytes("UTF-16LE");        for (byte b : byte5) {            System.out.print(Integer.toHexString(b & 0Xff) + " ");        }        System.out.println();        /*         * UTF-8中,三個字節表示漢字,兩個字節表示字母         */        byte[] byte6 = s.getBytes("UTF-8");        for (byte b : byte6) {            System.out.print(Integer.toHexString(b & 0Xff) + " ");        }        System.out.println();    }}

 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 分宜县| 竹北市| 惠来县| 万安县| 体育| 项城市| 乐业县| 梅河口市| 天等县| 锡林郭勒盟| 仲巴县| 安义县| 达孜县| 赫章县| 天气| 开原市| 南康市| 松原市| 集贤县| 敖汉旗| 达日县| 临夏市| 鄂州市| 西城区| 绥宁县| 武强县| 涞水县| 盐亭县| 新绛县| 桦川县| 东源县| 通州市| 宁阳县| 阿坝县| 潼关县| 三原县| 家居| 兴和县| 泰来县| 漳浦县| 越西县|