All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ionic.sdk.core.codec.UTF8 Maven / Gradle / Ivy

Go to download

The Ionic Java SDK provides an easy-to-use interface to the Ionic Platform.

There is a newer version: 2.9.0
Show newest version
package com.ionic.sdk.core.codec;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

/**
 * Utilities to provide conversions between UTF-8 encoded byte arrays and Java strings.
 */
public final class UTF8 implements BytesTranscoder {

    /**
     * Encode a UTF-8 byte[] as a string.
     *
     * @param bytes the input byte array (assumed to be encoded using the UTF-8 charset)
     * @return the equivalent Java string
     * @deprecated Please migrate usages to the replacement {@link Transcoder#utf8()} encode API.
     */
    @Deprecated
    @Override
    public String encode(final byte[] bytes) {
        return ((bytes == null) ? null : new String(bytes, UTF8));
    }

    /**
     * Encode a string as a UTF-8 byte[].
     *
     * @param string the input string
     * @return the UTF-8 encoded byte array
     * @deprecated Please migrate usages to the replacement {@link Transcoder#utf8()} decode API.
     */
    @Deprecated
    @Override
    public byte[] decode(final String string) {
        return ((string == null) ? null : string.getBytes(UTF8));
    }

    /**
     * Local reference to JVM definition of UTF-8 charset.
     */
    private static final Charset UTF8 = StandardCharsets.UTF_8;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy