public final class CharsetUtils
extends java.lang.Object
This class provides charset-dependent methods.
Modifier and Type | Field and Description |
---|---|
private static java.util.SortedMap<java.lang.String,java.nio.charset.Charset> |
availableCharsets |
private static java.lang.String |
CHARSET_JP |
private static java.lang.String |
CHARSET_LATIN |
private static java.util.regex.Pattern |
pattSwitchCharset |
Constructor and Description |
---|
CharsetUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
findCharsetSwitch(java.lang.String text)
Checks the given string for a new charset marker.
|
static byte[] |
getBytesFromText(java.lang.String text,
java.lang.String charset)
Converts a text into a byte array using the given charset, if possible.
|
static java.lang.String |
getTextFromBytes(byte[] bytes,
java.lang.String chosenCharset,
java.lang.String fileCharset)
Converts a byte array from a text-based MIDI message into a string.
|
private static final java.util.SortedMap<java.lang.String,java.nio.charset.Charset> availableCharsets
private static final java.util.regex.Pattern pattSwitchCharset
private static final java.lang.String CHARSET_LATIN
private static final java.lang.String CHARSET_JP
public static final java.lang.String getTextFromBytes(byte[] bytes, java.lang.String chosenCharset, java.lang.String fileCharset)
Converts a byte array from a text-based MIDI message into a string.
For the conversion the following charsets are tried:
bytes
- Byte array from the MIDI message.chosenCharset
- Charset chosen in the file selector.fileCharset
- Last charset declared in the sequence.public static final byte[] getBytesFromText(java.lang.String text, java.lang.String charset)
Converts a text into a byte array using the given charset, if possible.
text
- The text to be converted.charset
- The charset to be used for converting.public static final java.lang.String findCharsetSwitch(java.lang.String text)
Checks the given string for a new charset marker. If one or more such markers are found, returns the charset from the last tag. Otherwise: returns **null*.
text
- The text to be examinated.