测试方法:

alert("你好".replace(/[^\u0000-\u00FF]/g,function($0){return escape($0).replace(/(%u)(\w{4})/gi,"\\u$2")}))

将其封装为函数:

function toUnicode(str){
    return str.replace(/[^\u0000-\u00FF]/g,function($0){
        return escape($0).replace(/(%u)(\w{4})/gi,"\\u$2");
    });
}

相关文章:

  • 2021-11-25
  • 2022-01-14
  • 2022-01-20
  • 2022-12-23
  • 2021-11-01
  • 2021-07-16
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-23
  • 2021-11-28
  • 2022-12-23
  • 2022-12-23
  • 2022-01-08
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案