AAuto解析电话薄 VCF文件ENCODING=QUOTED-PRINTABLE编码解码

http://www.oschina.net/question/1438716_143767

import console
var t1 = "=31=33=37=E5=88=9B=E4=B8=9A"
// 解码
decode = function(s,utf8){
    s = string.replace(s,"<\=\x\x>+",
        function(c){   
            return eval("'" + ( string.replace( c,"\=","\\x") ) + "'" )  
        }
    ) 
    if(utf8) s= string.fromto(s,65001,0);
    return s; 
}

// 编码
encode = function(s,utf8){   
    if(utf8) s = string.fromto(s,0,65001);
    return  string.replace(s,"[^\.\-\_\~]",
        function(c){  
            return string.format("=%02X", c[1] )
        }
    )  
}

var t2 = decode(t1,"utf-8")
var t3 = encode(t2,"utf-8")
console.log("解码:",t2 );
console.log("编码:",t3 );

你可能感兴趣的:(编码,解码,vcf,aauto)