国产探花免费观看_亚洲丰满少妇自慰呻吟_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();    }}

 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 西昌市| 龙州县| 靖州| 台东市| 苍溪县| 兴安盟| 饶阳县| 永泰县| 贡嘎县| 简阳市| 洪泽县| 富川| 崇阳县| 泽普县| 灵石县| 高州市| 精河县| 乐亭县| 寿阳县| 蓬安县| 昭觉县| 长岛县| 山丹县| 江北区| 庆云县| 景泰县| 博野县| 安西县| 南安市| 富顺县| 东乌珠穆沁旗| 长汀县| 濮阳县| 安新县| 桦甸市| 万载县| 营口市| 库尔勒市| 前郭尔| 德保县| 密云县|