Package com.mysql.cj

Class CharsetMapping

java.lang.Object
com.mysql.cj.CharsetMapping

public class CharsetMapping
extends java.lang.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 :(
  • Field Details

  • Constructor Details

  • Method Details

    • getMysqlCharsetForJavaEncoding

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

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

      public static java.lang.String getMysqlCharsetNameForCollationIndex​(java.lang.Integer collationIndex)
    • getJavaEncodingForMysqlCharset

      public static java.lang.String getJavaEncodingForMysqlCharset​(java.lang.String mysqlCharsetName, java.lang.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)
      Parameters:
      mysqlCharsetName - MySQL charset name
      javaEncoding - fall-back java encoding name
      Returns:
      java encoding name
    • getJavaEncodingForMysqlCharset

      public static java.lang.String getJavaEncodingForMysqlCharset​(java.lang.String mysqlCharsetName)
    • getJavaEncodingForCollationIndex

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

      public static java.lang.String getJavaEncodingForCollationIndex​(java.lang.Integer collationIndex)
    • getNumberOfCharsetsConfigured

      public static final int getNumberOfCharsetsConfigured()
    • isMultibyteCharset

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

      public static int getMblen​(java.lang.String charsetName)