flash把string转化为16进制
程序员文章站
2022-05-19 20:00:52
...
String读入到ByteArray中,然后把byte转化成10进制,再输出成16进制。
function doclick(e:MouseEvent) { txt1.text = ""; var rawdata:String = ""; var handleresult:String; rawdata = txt.text; 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); } txt1.text = handleresult.substr(4,handleresult.length-4); } btn.addEventListener(MouseEvent.CLICK,doclick);