Class SingleByteCharsetConverter
java.lang.Object
com.mysql.jdbc.SingleByteCharsetConverter
Converter for char[]->byte[] and byte[]->char[] for single-byte character sets.
-
Method Summary
Modifier and TypeMethodDescriptionstatic SingleByteCharsetConvertergetInstance(String encodingName, Connection conn) Get a converter for the given encoding namestatic SingleByteCharsetConverterinitCharset(String javaEncodingName) Initialize the shared instance of a converter for the given character encoding.final byte[]toBytes(char[] c) final byte[]toBytes(char[] chars, int offset, int length) final byte[]Convert the given string to an array of bytes.final byte[]Convert the given string to an array of bytes.final byte[]toBytesWrapped(char[] c, char beginWrap, char endWrap) final byte[]toBytesWrapped(String s, char beginWrap, char endWrap) final StringtoString(byte[] buffer) Convert the byte buffer to a string using this instance's character encoding.final StringtoString(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.static StringtoStringDefaultEncoding(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.
-
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 nameconn-- Returns:
- a converter for the given encoding name
- Throws:
UnsupportedEncodingException- if the character encoding is not supportedSQLException
-
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 supportedSQLException
-
toStringDefaultEncoding
Convert the byte buffer from startPos to a length of length to a string using the default platform encoding.- Parameters:
buffer- the bytes to convertstartPos- the index to start atlength- 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
Convert the given string to an array of bytes.- Parameters:
s- the String to convert- Returns:
- the bytes that make up the String
-
toBytesWrapped
-
toBytes
Convert the given string to an array of bytes.- Parameters:
s- the String to convertoffset- the offset to start atlength- length (max) to convert- Returns:
- the bytes that make up the String
-
toString
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
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 convertstartPos- the index to start atlength- the number of bytes to convert- Returns:
- the String representation of the given bytes
-