程序包 com.mysql.cj

类 CharsetMapping


  • public class CharsetMapping
    extends Object
    Mapping between MySQL charset names and Java charset names. I've investigated placing these in a .properties file, but unfortunately under most appservers this complicates configuration because the security policy needs to be changed by the user to allow the driver to read them :(
    • 字段详细资料

      • COLLATION_INDEX_TO_COLLATION_NAME

        public static final String[] COLLATION_INDEX_TO_COLLATION_NAME
      • COLLATION_INDEX_TO_CHARSET

        public static final com.mysql.cj.MysqlCharset[] COLLATION_INDEX_TO_CHARSET
      • CHARSET_NAME_TO_CHARSET

        public static final Map<String,​com.mysql.cj.MysqlCharset> CHARSET_NAME_TO_CHARSET
      • CHARSET_NAME_TO_COLLATION_INDEX

        public static final Map<String,​Integer> CHARSET_NAME_TO_COLLATION_INDEX
      • UTF8MB4_INDEXES

        public static final Set<Integer> UTF8MB4_INDEXES
      • MYSQL_COLLATION_INDEX_utf8

        public static final int MYSQL_COLLATION_INDEX_utf8
        另请参阅:
        常量字段值
      • MYSQL_COLLATION_INDEX_binary

        public static final int MYSQL_COLLATION_INDEX_binary
        另请参阅:
        常量字段值
    • 构造器详细资料

      • CharsetMapping

        public CharsetMapping()
    • 方法详细资料

      • getMysqlCharsetForJavaEncoding

        public static final String getMysqlCharsetForJavaEncoding​(String javaEncoding,
                                                                  ServerVersion version)
      • getCollationIndexForJavaEncoding

        public static int getCollationIndexForJavaEncoding​(String javaEncoding,
                                                           ServerVersion version)
      • getMysqlCharsetNameForCollationIndex

        public static String getMysqlCharsetNameForCollationIndex​(Integer collationIndex)
      • getJavaEncodingForMysqlCharset

        public static String getJavaEncodingForMysqlCharset​(String mysqlCharsetName,
                                                            String javaEncoding)
        MySQL charset could map to several Java encodings. So here we choose the one according to next rules:
        • if there is no static mapping for this charset then return javaEncoding value as is because this could be a custom charset for example
        • if static mapping exists and javaEncoding equals to one of Java encoding canonical names or aliases available for this mapping then javaEncoding value as is; this is required when result should match to connection encoding, for example if connection encoding is Cp943 we must avoid getting SHIFT_JIS for sjis mysql charset
        • if static mapping exists and javaEncoding doesn't match any Java encoding canonical names or aliases available for this mapping then return default Java encoding (the first in mapping list)
        参数:
        mysqlCharsetName - MySQL charset name
        javaEncoding - fall-back java encoding name
        返回:
        java encoding name
      • getJavaEncodingForMysqlCharset

        public static String getJavaEncodingForMysqlCharset​(String mysqlCharsetName)
      • getJavaEncodingForCollationIndex

        public static String getJavaEncodingForCollationIndex​(Integer collationIndex,
                                                              String javaEncoding)
      • getJavaEncodingForCollationIndex

        public static String getJavaEncodingForCollationIndex​(Integer collationIndex)
      • getNumberOfCharsetsConfigured

        public static final int getNumberOfCharsetsConfigured()
      • isMultibyteCharset

        public static final boolean isMultibyteCharset​(String javaEncodingName)
        Does the character set contain multi-byte encoded characters.
        参数:
        javaEncodingName - java encoding name
        返回:
        true if the character set contains multi-byte encoded characters.
      • getMblen

        public static int getMblen​(String charsetName)