Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function convertToUnicode(str) {
- return str.replace(/[\u0080-\uffff]+/g, function (match) {
- return escape(match).replace(/%u/g, "\\u");
- }).toLowerCase();
- }
- let obj = {
- a: convertToUnicode('あ');
- b: convertToUnicode('い');
- c: convertToUnicode('う');
- }
- // JSON.stringify add escape "\". So, replace the escape.
- let str = JSON.stringify(obj).replace(/\\\\/g,'\\');
Add Comment
Please, Sign In to add comment