Q:

convert UTF 8 string codes(codes are holded in string variable) into UTF 16 string(actual utf 16 chars)

I have converted UTF 16 to UTF 8 (method used : toUTF8Array)codes in javascript and sent the code from ajax call(note : UTF 16 chars is ugly and it needed encoding which I dont want!)
Js code :
var compressed = LZString.compressToUTF16(uncompressed64Data);
var utf8values = toUTF8Array(compressed); 
    jQuery.ajax({
data :"img=+" utf8values 
}

I have received the UTF 8 codes in java server side as follow :
 String utf8values = request.getParameter("img");

fyi, outcome of sop:
utf8values : 225,186,162,227,160,181,229,160,165
Now I want change the codes into actual UTF 16 string?
Thanks in advance!

A:

The following should work:
String[] split = "225,186,162,227,160,181,229,160,165".split(",");
ByteBuffer bb = ByteBuffer.allocate(split.length);
Arrays.stream(split).forEach(a -> bb.put((byte)Integer.parseInt(a)));
bb.flip();
String string = Charset.forName("UTF-8").decode(bb).toString();

