Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { public static String utf16to8(String str) { int i = 0, len = str.length(), c; String out = ""; while (i < len) { c = str.charAt(i); if ((c >= 0x0001) && (c <= 0x007F)) { out += str.charAt(i); } else if (c > 0x07FF) { out += (char) (0xE0 | ((c >> 12) & 0x0F)); out += (char) (0x80 | ((c >> 6) & 0x3F)); out += (char) (0x80 | (c & 0x3F)); } else { out += (char) (0xC0 | ((c >> 6) & 0x1F)); out += (char) (0x80 | (c & 0x3F)); } i++; } return out; } }