亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? singlebytecharsetconverter.java

?? jsp數據庫系統
?? JAVA
字號:
/*
   Copyright (C) 2002 MySQL AB

      This program is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published by
      the Free Software Foundation; either version 2 of the License, or
      (at your option) any later version.

      This program is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      GNU General Public License for more details.

      You should have received a copy of the GNU General Public License
      along with this program; if not, write to the Free Software
      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

 */
package com.mysql.jdbc;

import java.io.UnsupportedEncodingException;

import java.util.HashMap;
import java.util.Map;


/**
 * Converter for char[]->byte[] and byte[]->char[] for single-byte character
 * sets. Much faster (5-6x) than the built-in solution that ships with the
 * JVM, even with JDK-1.4.x and NewIo.
 *
 * @author Mark Matthews
 */
public class SingleByteCharsetConverter {
    // The initial charToByteMap, with all char mappings mapped 
    // to (byte) '?', so that unknown characters are mapped to '?'
    // instead of '\0' (which means end-of-string to MySQL).
    private static byte[] unknownCharsMap = new byte[65536];
    private static final int BYTE_RANGE = (1 + Byte.MAX_VALUE) - Byte.MIN_VALUE;
    private static final Map CONVERTER_MAP = new HashMap();
    private static byte[] allBytes = new byte[BYTE_RANGE];

    static {
        for (int i = Byte.MIN_VALUE; i <= Byte.MAX_VALUE; i++) {
            allBytes[i - Byte.MIN_VALUE] = (byte) i;
        }

        for (int i = 0; i < unknownCharsMap.length; i++) {
            unknownCharsMap[i] = (byte) '?'; // use something 'sane' for unknown chars
        }
    }

    private char[] byteToChars = new char[BYTE_RANGE];
    private byte[] charToByteMap = new byte[65536];

    /**
     * Prevent instantiation, called out of static method initCharset().
     *
     * @param encodingName a JVM character encoding
     *
     * @throws UnsupportedEncodingException if the JVM does not support the
     *         encoding
     */
    private SingleByteCharsetConverter(String encodingName)
        throws UnsupportedEncodingException {
        String allBytesString = new String(allBytes, 0, BYTE_RANGE, encodingName);
        int allBytesLen = allBytesString.length();

        System.arraycopy(unknownCharsMap, 0, charToByteMap, 0,
            charToByteMap.length);

        for (int i = 0; (i < BYTE_RANGE) && (i < allBytesLen); i++) {
            char c = allBytesString.charAt(i);
            byteToChars[i] = c;
            charToByteMap[c] = allBytes[i];
        }
    }

    /**
     * Get a converter for the given encoding name
     *
     * @param encodingName the Java character encoding name
     *
     * @return a converter for the given encoding name
     *
     * @throws UnsupportedEncodingException if the character encoding is not
     *         supported
     */
    public static synchronized SingleByteCharsetConverter getInstance(
        String encodingName) throws UnsupportedEncodingException {
        SingleByteCharsetConverter instance = (SingleByteCharsetConverter) CONVERTER_MAP
            .get(encodingName);

        if (instance == null) {
            instance = initCharset(encodingName);
        }

        return instance;
    }

    /**
     * Initialize the shared instance of a converter for the given character
     * encoding.
     *
     * @param javaEncodingName the Java name for the character set to
     *        initialize
     *
     * @return a converter for the given character set
     *
     * @throws UnsupportedEncodingException if the character encoding is not
     *         supported
     */
    public static SingleByteCharsetConverter initCharset(
        String javaEncodingName) throws UnsupportedEncodingException {
        String mysqlEncodingName = (String) CharsetMapping.JAVA_TO_MYSQL_CHARSET_MAP
            .get(javaEncodingName);

        if (mysqlEncodingName == null) {
            return null;
        }

        if (CharsetMapping.MULTIBYTE_CHARSETS.containsKey(mysqlEncodingName)) {
            return null;
        }

        SingleByteCharsetConverter converter = new SingleByteCharsetConverter(javaEncodingName);

        CONVERTER_MAP.put(javaEncodingName, converter);

        return converter;
    }

    /**
     * Convert the byte buffer from startPos to a length of length to a string
     * using the default platform encoding.
     *
     * @param buffer the bytes to convert
     * @param startPos the index to start at
     * @param length the number of bytes to convert
     *
     * @return the String representation of the given bytes
     */
    public static String toStringDefaultEncoding(byte[] buffer, int startPos,
        int length) {
        return new String(buffer, startPos, length);
    }

    /**
     * Convert the given string to an array of bytes.
     *
     * @param s the String to convert
     *
     * @return the bytes that make up the String
     */
    public final byte[] toBytes(String s) {
        if (s == null) {
            return null;
        }

        int length = s.length();
        byte[] bytes = new byte[length];

        for (int i = 0; i < length; i++) {
            char c = s.charAt(i);
            bytes[i] = charToByteMap[c];
        }

        return bytes;
    }

    private final static byte[] EMPTY_BYTE_ARRAY = new byte[0];
    
    /**
     * Convert the given string to an array of bytes.
     *
     * @param s the String to convert
     * @param offset the offset to start at
     * @param length length (max) to convert
     *
     * @return the bytes that make up the String
     */
    public final byte[] toBytes(String s, int offset, int length) {
        if (s == null) {
            return null;
        }

        if (length == 0) {
        	return EMPTY_BYTE_ARRAY;
        }
        
        int stringLength = s.length();
        byte[] bytes = new byte[length];

       
        for (int i = 0; (i < length); i++) {
            char c = s.charAt(i + offset);
            bytes[i] = charToByteMap[c];
        }

        return bytes;
    }

    /**
     * Convert the byte buffer to a string using this instance's character
     * encoding.
     *
     * @param buffer the bytes to convert to a String
     *
     * @return the converted String
     */
    public final String toString(byte[] buffer) {
        return toString(buffer, 0, buffer.length);
    }

    /**
     * Convert the byte buffer from startPos to a length of length to a string
     * using this instance's character encoding.
     *
     * @param buffer the bytes to convert
     * @param startPos the index to start at
     * @param length the number of bytes to convert
     *
     * @return the String representation of the given bytes
     */
    public final String toString(byte[] buffer, int startPos, int length) {
        char[] charArray = new char[length];
        int readpoint = startPos;

        for (int i = 0; i < length; i++) {
            charArray[i] = byteToChars[(int) buffer[readpoint] - Byte.MIN_VALUE];
            readpoint++;
        }

        return new String(charArray);
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩免费观看一区二区三区| 国产欧美日韩在线观看| 国产日产亚洲精品系列| 亚洲一区二区三区在线看| 精品中文字幕一区二区| 91国偷自产一区二区三区观看| 91精品一区二区三区在线观看| 国产精品色哟哟网站| 久久99精品久久久久久久久久久久| jlzzjlzz亚洲日本少妇| 日韩一区二区三区在线视频| 亚洲精品福利视频网站| 国产.精品.日韩.另类.中文.在线.播放 | 成人短视频下载| 欧美大片国产精品| 香蕉成人伊视频在线观看| 成人免费毛片片v| 3751色影院一区二区三区| 亚洲日本在线视频观看| av资源网一区| 成人免费在线视频观看| 波多野结衣91| 中文字幕在线观看一区二区| 国产不卡视频在线播放| 久久久夜色精品亚洲| 国产一区视频导航| 久久久久国产精品免费免费搜索| 另类调教123区| 7777精品伊人久久久大香线蕉最新版 | 久久久夜色精品亚洲| 久久精品99久久久| 欧美刺激午夜性久久久久久久| 洋洋成人永久网站入口| 欧美性受xxxx黑人xyx| 亚洲一区二区三区国产| 欧美亚洲免费在线一区| 亚洲一区二区三区国产| 欧美精品一二三| 日韩av电影免费观看高清完整版在线观看| 欧美综合亚洲图片综合区| 亚洲地区一二三色| 久久你懂得1024| 国产在线观看一区二区| 2017欧美狠狠色| 丁香桃色午夜亚洲一区二区三区| 国产欧美一区视频| 91啪九色porn原创视频在线观看| 18涩涩午夜精品.www| 在线亚洲精品福利网址导航| 午夜精品久久一牛影视| 欧美大度的电影原声| 国产精品主播直播| 国产精品激情偷乱一区二区∴| 色综合av在线| 奇米综合一区二区三区精品视频| 欧美电影免费观看高清完整版在 | 午夜视频久久久久久| 日韩欧美国产综合在线一区二区三区| 免费高清成人在线| 国产日本一区二区| 在线观看日韩国产| 黑人巨大精品欧美一区| 中文字幕一区视频| 欧美一区二区在线看| 国产1区2区3区精品美女| 亚洲主播在线观看| 久久久精品国产免费观看同学| 99久久99久久精品国产片果冻| 日日夜夜精品视频天天综合网| 久久中文字幕电影| 色噜噜狠狠色综合中国| 蜜桃久久久久久| 亚洲日穴在线视频| 久久综合九色综合欧美亚洲| 91免费国产在线观看| 日韩制服丝袜av| 国产精品卡一卡二| 欧美一区二区免费视频| 色综合天天性综合| 久久99精品国产.久久久久久| ●精品国产综合乱码久久久久| 欧美一区二区免费视频| 在线日韩av片| 国产成a人无v码亚洲福利| 视频在线观看国产精品| 午夜精品一区在线观看| 国产精品美日韩| 日韩欧美高清在线| 91福利视频网站| 国产成+人+日韩+欧美+亚洲| 天堂精品中文字幕在线| 亚洲精品成a人| 亚洲国产高清在线观看视频| 91.xcao| 在线视频国产一区| 99视频精品在线| youjizz国产精品| 国产激情视频一区二区三区欧美 | 久久久久久久网| 欧美一区二区视频在线观看2020 | 成人免费看视频| 美女视频一区在线观看| 亚洲va欧美va人人爽| 亚洲日本一区二区三区| 国产精品免费免费| 中文一区在线播放| 26uuuu精品一区二区| 91精品国产91久久久久久最新毛片| 色天天综合色天天久久| 91麻豆国产福利精品| 99视频精品全部免费在线| 成人午夜av电影| 不卡的av中国片| av在线播放一区二区三区| 国产成人免费高清| 国产成人精品免费在线| 国产+成+人+亚洲欧洲自线| 懂色av一区二区三区免费看| 成人精品亚洲人成在线| 东方aⅴ免费观看久久av| 99免费精品视频| 色综合久久中文综合久久97| 欧美色网站导航| 91麻豆精品国产91久久久更新时间| 欧美在线免费播放| 欧美二区三区的天堂| 欧美电影免费观看完整版| 欧美xxxxxxxxx| 国产精品久久久久桃色tv| 亚洲欧洲制服丝袜| 午夜精品久久久久久| 精一区二区三区| 成人a级免费电影| 欧美性大战久久| 中文字幕不卡在线观看| 亚洲精品欧美综合四区| 图片区小说区区亚洲影院| 理论片日本一区| 成人高清视频在线| 成人高清免费观看| 欧美日韩精品二区第二页| 久久婷婷色综合| 亚洲日本一区二区三区| 蜜桃视频第一区免费观看| 成人av在线资源网站| 欧美色手机在线观看| 精品国产麻豆免费人成网站| 亚洲视频在线一区二区| 另类成人小视频在线| 91性感美女视频| 欧美一级免费观看| 国产精品久久国产精麻豆99网站 | 精品成人在线观看| 国产精品污网站| 亚洲激情自拍偷拍| 精品综合免费视频观看| 一本久久精品一区二区| 欧美tickling挠脚心丨vk| 亚洲欧美在线观看| 韩国成人福利片在线播放| 91国产丝袜在线播放| 精品sm捆绑视频| 午夜视频在线观看一区二区三区| 国产成人免费视频网站高清观看视频| 欧美日韩另类国产亚洲欧美一级| 国产亚洲一区二区三区四区| 亚洲午夜一区二区三区| 丰满白嫩尤物一区二区| 日韩丝袜美女视频| 亚洲自拍欧美精品| 成人黄色在线网站| 久久色在线观看| 蜜桃久久久久久久| 欧美精品tushy高清| 亚洲欧美另类久久久精品2019| 国产一区二区三区在线观看精品| 欧美最猛性xxxxx直播| 国产精品久久久久久亚洲伦| 狠狠色综合播放一区二区| 51精品国自产在线| 亚洲成人中文在线| 色视频成人在线观看免| 国产精品高潮久久久久无| 国产精品一色哟哟哟| 欧美tickling网站挠脚心| 男人的j进女人的j一区| 欧美系列一区二区| 一级中文字幕一区二区| 92国产精品观看| 国产精品久久久久一区二区三区| 久久99热这里只有精品| 日韩亚洲电影在线| 欧美a一区二区| 欧美一区二区视频观看视频| 日本中文字幕一区二区视频| 欧美日韩久久久| 调教+趴+乳夹+国产+精品| 欧美日韩国产三级| 视频一区视频二区中文字幕| 91精品在线免费|