Unknown
private function strToUTF16( str:String ):ByteArray

{

var utf16:ByteArray = new ByteArray();

var iChar:uint;

var i:uint=0, iLen:uint = str.length;



/* BOM first */

utf16.writeByte( 0xFF );

utf16.writeByte( 0xFE );



while ( i < iLen )
{
iChar = str.charCodeAt(i);
trace( iChar );

if ( iChar < 0xFF )
{
/* one byte char */
utf16.writeByte( iChar );
utf16.writeByte( 0 );
}
else
{
/* two byte char */
utf16.writeByte( iChar & 0x00FF );
utf16.writeByte( iChar >> 8 );

}



i++;

}



return utf16;

}
Nhãn: , | edit post
0 Responses

Đăng nhận xét