Class SingleByteCharsetConverter

java.lang.Object
com.mysql.jdbc.SingleByteCharsetConverter

public class SingleByteCharsetConverter extends Object
Converter for char[]->byte[] and byte[]->char[] for single-byte character sets.
  • Method Details

    • getInstance

      public static SingleByteCharsetConverter getInstance(String encodingName, Connection conn) throws UnsupportedEncodingException, SQLException
      Get a converter for the given encoding name
      Parameters:
      encodingName - the Java character encoding name
      conn -
      Returns:
      a converter for the given encoding name
      Throws:
      UnsupportedEncodingException - if the character encoding is not supported
      SQLException
    • initCharset

      public static SingleByteCharsetConverter initCharset(String javaEncodingName) throws UnsupportedEncodingException, SQLException
      Initialize the shared instance of a converter for the given character encoding.
      Parameters:
      javaEncodingName - the Java name for the character set to initialize
      Returns:
      a converter for the given character set
      Throws:
      UnsupportedEncodingException - if the character encoding is not supported
      SQLException
    • toStringDefaultEncoding

      public static String toStringDefaultEncoding(byte[] buffer, int startPos, int length)
      Convert the byte buffer from startPos to a length of length to a string using the default platform encoding.
      Parameters:
      buffer - the bytes to convert
      startPos - the index to start at
      length - the number of bytes to convert
      Returns:
      the String representation of the given bytes
    • toBytes

      public final byte[] toBytes(char[] c)
    • toBytesWrapped

      public final byte[] toBytesWrapped(char[] c, char beginWrap, char endWrap)
    • toBytes

      public final byte[] toBytes(char[] chars, int offset, int length)
    • toBytes

      public final byte[] toBytes(String s)
      Convert the given string to an array of bytes.
      Parameters:
      s - the String to convert
      Returns:
      the bytes that make up the String
    • toBytesWrapped

      public final byte[] toBytesWrapped(String s, char beginWrap, char endWrap)
    • toBytes

      public final byte[] toBytes(String s, int offset, int length)
      Convert the given string to an array of bytes.
      Parameters:
      s - the String to convert
      offset - the offset to start at
      length - length (max) to convert
      Returns:
      the bytes that make up the String
    • toString

      public final String toString(byte[] buffer)
      Convert the byte buffer to a string using this instance's character encoding.
      Parameters:
      buffer - the bytes to convert to a String
      Returns:
      the converted String
    • toString

      public final String toString(byte[] buffer, int startPos, int length)
      Convert the byte buffer from startPos to a length of length to a string using this instance's character encoding.
      Parameters:
      buffer - the bytes to convert
      startPos - the index to start at
      length - the number of bytes to convert
      Returns:
      the String representation of the given bytes