Example usage for org.apache.commons.codec Charsets UTF_16LE

List of usage examples for org.apache.commons.codec Charsets UTF_16LE

Introduction

In this page you can find the example usage for org.apache.commons.codec Charsets UTF_16LE.

Prototype

Charset UTF_16LE

To view the source code for org.apache.commons.codec Charsets UTF_16LE.

Click Source Link

Document

Sixteen-bit Unicode Transformation Format, little-endian byte order.

Usage

From source file:com.anrisoftware.prefdialog.csvimportdialog.panelproperties.panelproperties.CsvPanelPropertiesModule.java

@SuppressWarnings("deprecation")
@Provides//from  w  w w .  j a v  a2 s . c  om
@Singleton
@Named("charsetDefaults")
Collection<Charset> getCharsetDefaults() {
    List<Charset> list = new ArrayList<Charset>();
    list.add(Charsets.UTF_8);
    list.add(Charsets.UTF_16);
    list.add(Charsets.UTF_16BE);
    list.add(Charsets.UTF_16LE);
    list.add(Charsets.US_ASCII);
    list.add(Charsets.ISO_8859_1);
    return list;
}

From source file:com.yhspy.zbartest.StringUtils.java

/**
 * Encodes the given string into a sequence of bytes using the UTF-16LE charset, storing the result into a new byte
 * array./*from   w  w  w.  j av  a2s  .  c o m*/
 *
 * @param string
 *            the String to encode, may be {@code null}
 * @return encoded bytes, or {@code null} if the input string was {@code null}
 * @throws NullPointerException
 *             Thrown if {@link Charsets#UTF_16LE} is not initialized, which should never happen since it is
 *             required by the Java platform specification.
 * @since As of 1.7, throws {@link NullPointerException} instead of UnsupportedEncodingException
 * @see <a href="http://download.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
 * @see #getBytesUnchecked(String, String)
 */
public static byte[] getBytesUtf16Le(final String string) {
    return getBytes(string, Charsets.UTF_16LE);
}

From source file:com.yhspy.zbartest.StringUtils.java

/**
 * Constructs a new <code>String</code> by decoding the specified array of bytes using the UTF-16LE charset.
 *
 * @param bytes/*w w  w . j a v a2s . c o  m*/
 *            The bytes to be decoded into characters
 * @return A new <code>String</code> decoded from the specified array of bytes using the UTF-16LE charset,
 *         or {@code null} if the input byte array was {@code null}.
 * @throws NullPointerException
 *             Thrown if {@link Charsets#UTF_16LE} is not initialized, which should never happen since it is
 *             required by the Java platform specification.
 * @since As of 1.7, throws {@link NullPointerException} instead of UnsupportedEncodingException
 */
public static String newStringUtf16Le(final byte[] bytes) {
    return new String(bytes, Charsets.UTF_16LE);
}