How to convert large UTF-8 strings into ASCII?

前端 未结 9 1746
盖世英雄少女心
盖世英雄少女心 2020-12-18 08:29

I need to convert large UTF-8 strings into ASCII. It should be reversible, and ideally a quick/lightweight algorithm.

How can I do this? I need the source

9条回答
  •  情书的邮戳
    2020-12-18 09:07

    An implementation of the quote() function might do what you want. My version can be found here

    You can use eval() to reverse the encoding:

    var foo = 'Hägar';
    var quotedFoo = quote(foo);
    var unquotedFoo = eval(quotedFoo);
    alert(foo === unquotedFoo);
    

提交回复
热议问题