function stringTo16(_s:String="A"):void{ var s1 = ""; var rawdata:String = ""; var handleresult:String; rawdata = _s; var byte:ByteArray=new ByteArray(); byte.writeMultiByte(rawdata,"utf-8"); for (var i:int; i<byte.length; i++) { var num:Number = parseInt(byte[i],10); handleresult += "%" + num.toString(16); } s1 = handleresult.substr(4,handleresult.length-4); trace(s1); }
输出的s1应该为41