
// -------------------------------------------------------------------------
// Unicode convertion functions
// -------------------------------------------------------------------------

// convert a string into unicode form (bytes)
function convertUnicodeToUTF8(s) {
	var i;
	var l = s.length;
	var u = "";
	for (i = 0; i < l; ++i) {
		var c = s.charCodeAt(i);
		if (c < 0x00080) {
			u += String.fromCharCode(c & 0xFF);
		} else if (c < 0x00800) {
			u +=
				String.fromCharCode(0xC0 + ((c >> 6) & 0x1F)) +
				String.fromCharCode(0x80 + (c & 0x3F));
		} else if (c < 0x10000) {
			u +=
				String.fromCharCode(0xE0 + ((c >> 12) & 0x0F)) +
				String.fromCharCode(0x80 + ((c >> 6) & 0x3F)) +
				String.fromCharCode(0x80 + (c & 0x3F));
		} else {
			u +=
				String.fromCharCode(0xF0 + ((c >> 18) & 0x07)) +
				String.fromCharCode(0x80 + ((c >> 12) & 0x3F)) +
				String.fromCharCode(0x80 + ((c >> 6) & 0x3F)) +
				String.fromCharCode(0x80 + (c & 0x3F));
		}
	}
	return u;
}