// Version : 1.003
// Original File Name : EinsUTF8Lib.js
// Last Modified : 2008/11/20
// Copyright(c) 2007 NewType Inortech. All Rights Reserved. http://www.newtype.com.tw
// Originally published and documented at http://www.einstand.idv.tw
//
EinsUTF8Lib=function(){};EinsUTF8Lib.prototype.UTF16to8=function(str){var a04="";var a03=str.length;for(var i=0;i<a03;i++){var c=str.charCodeAt(i);if((c>=0x0001)&&(c<=0x007F)){a04+=str.charAt(i);}else if(c>0x07FF){a04+=String.fromCharCode(0xE0|((c>>12)&0x0F));a04+=String.fromCharCode(0x80|((c>>6)&0x3F));a04+=String.fromCharCode(0x80|((c>>0)&0x3F));}else{a04+=String.fromCharCode(0xC0|((c>>6)&0x1F));a04+=String.fromCharCode(0x80|((c>>0)&0x3F));}}return a04;};EinsUTF8Lib.prototype.UTF8to16=function(str){var a01,a02;var a04="";var a03=str.length;var i=0;while(i<a03){var c=str.charCodeAt(i++);switch(c>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:a04+=str.charAt(i-1);break;case 12:case 13:a01=str.charCodeAt(i++);a04+=String.fromCharCode(((c&0x1F)<<6)|(a01&0x3F));break;case 14:a01=str.charCodeAt(i++);a02=str.charCodeAt(i++);a04+=String.fromCharCode(((c&0x0F)<<12)|((a01&0x3F)<<6)|((a02&0x3F)<<0));break;}}return a04;};
