乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      將中文轉(zhuǎn)為unicode 及轉(zhuǎn)回中文函數(shù)

       duduwolf 2006-03-03
      //轉(zhuǎn)為unicode
      public static void writeUnicode(final DataOutputStream out, final String value)  {
        try {
        final String unicode = gbEncoding( value );
        final byte[] data = unicode.getBytes();
        final int dataLength = data.length;

        System.out.println( "Data Length is: " + dataLength );
        System.out.println( "Data is: " + value );
        out.writeInt( dataLength ); //先寫(xiě)出字符串的長(zhǎng)度
        out.write( data, 0, dataLength ); //然后寫(xiě)出轉(zhuǎn)化后的字符串
        } catch (IOException e) {
       
        }
        }

       
        public static String gbEncoding( final String gbString ) {
        char[] utfBytes = gbString.toCharArray();
        String unicodeBytes = "";
        for( int byteIndex = 0; byteIndex < utfBytes.length; byteIndex ++ ) {
        String hexB = Integer.toHexString( utfBytes[ byteIndex ] );
        if( hexB.length() <= 2 ) {
        hexB = "00" + hexB;
        }
        unicodeBytes = unicodeBytes + "\\\\u" + hexB;
        }
        System.out.println( "unicodeBytes is: " + unicodeBytes );
        return unicodeBytes;
        }




      /*****************************************************
        * 功能介紹:將unicode字符串轉(zhuǎn)為漢字
        * 輸入?yún)?shù):源unicode字符串
        * 輸出參數(shù):轉(zhuǎn)換后的字符串
        *****************************************************/
       private String decodeUnicode( final String dataStr ) {
        int start = 0;
        int end = 0;
        final StringBuffer buffer = new StringBuffer();
        while( start > -1 ) {
        end = dataStr.indexOf( "\\\\u", start + 2 );
        String charStr = "";
        if( end == -1 ) {
        charStr = dataStr.substring( start + 2, dataStr.length() );
        } else {
        charStr = dataStr.substring( start + 2, end);
        }
        char letter = (char) Integer.parseInt( charStr, 16 ); // 16進(jìn)制parse整形字符串。
        buffer.append( new Character( letter ).toString() );
        start = end;
        }
        return buffer.toString();
       }

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類(lèi)似文章 更多