About

<#TEMPLATE_INCLUDE_NINEPAGE_ABOUTME#>
  • Jan

    19

    [AS1/2/3]字符串unicode编/解码

    • 0 Comments
    • Flash Platform
    //字符串转换成unicode映射
    function unicode_escape(string:String):String {
        var _string:String = string;
        var _arr:Array = new Array();
        for (var n:Number = 0; n<_string.length; n++) {
            _arr[n] = "0x"+_string.charCodeAt(n).toString(16);
        }
        _string = _arr.join("/");
        return _string;
    }
    trace(unicode_escape("ab:c&*^&("));
    //unicode解码成字符串
    function unicode_unescape(string:String, delimiter:String):String {
        var _string:String = string;
        var _arr:Array = _string.split(delimiter);
        for (var n:Number = 0; n<_arr.length; n++) {
            _arr[n] = String.fromCharCode(_arr[n]);
        }
        _string = _arr.join("");
        return _string;
    }
    trace(unicode_unescape("0x61/0x62/0xff1a/0x63/0x26/0x2a/0x5e/0x26/0x28", "/"));