Here you can find the source of convertFromUnicode(String input, String targetCharset)
public static String convertFromUnicode(String input, String targetCharset)
//package com.java2s; //License from project: Apache License import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.CharacterCodingException; import java.nio.charset.Charset; import java.nio.charset.CharsetDecoder; public class Main { public static String convertFromUnicode(String input, String targetCharset) { // Create the encoder and decoder for inCharset Charset charset = Charset.forName(targetCharset); CharsetDecoder decoder = charset.newDecoder(); CharBuffer cbuf = null;//from w ww . j av a 2 s . c o m try { // Convert ISO-LATIN-1 bytes in a ByteBuffer to a character // ByteBuffer and then to a // string. // The newstate ByteBuffer is ready to be read. cbuf = decoder.decode(ByteBuffer.wrap(input.getBytes())); } catch (CharacterCodingException e) { // LOG.logError( e.getMessage(), e ); } return cbuf.toString(); } }