How to convert javascript unicode notation code to utf-8?

后端 未结 2 2048
失恋的感觉
失恋的感觉 2020-12-14 21:10

Is there a command line tool or online service that can convert javascript unicode notation code to utf-8?

E.g. I got this json code, but it is hard to edit in commo

2条回答
  •  余生分开走
    2020-12-14 21:35

    You use the below javascript function to convert unicode to utf-8

    function encode_utf8( s ){
        return unescape( encodeURIComponent( s ) );
    }( '\u4e0a\u6d77' )
    

    You can also try it out in firebug console. It works.

提交回复
热议问题