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

com.ning.api.client.auth.UTF8Codec Maven / Gradle / Ivy

There is a newer version: 0.5.1
Show newest version
package com.ning.api.client.auth;

import java.nio.charset.Charset;

/**
 * Wrapper class for (more) efficient UTF-8 encoding and decoding
 */
public class UTF8Codec
{
    private final Charset utf8;
    
    public UTF8Codec() {
        utf8 = Charset.forName("UTF-8");
    }

    public byte[] toUTF8(String input) {
        return input.getBytes(utf8);
    }

    public String fromUTF8(byte[] input) {
        return fromUTF8(input, 0, input.length);
    }
    
    public String fromUTF8(byte[] input, int offset, int len) {
        return new String(input, offset, len, utf8);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy