| 316 | } |
| 317 | |
| 318 | export function uniDecode(text) { |
| 319 | text = text.replace(/(\\)?\\u/gi, '%u').replace('%u0025', '%25'); |
| 320 | text = unescape(text.toString().replace(/%2B/g, '+')); |
| 321 | const matches = text.match(/(%u00([0-9A-F]{2}))/gi); |
| 322 | if (matches) { |
| 323 | for (const m of matches) { |
| 324 | const code = m.substring(1, 3); |
| 325 | const x = Number('0x' + code); |
| 326 | if (x >= 128) text = text.replace(m, code); |
| 327 | } |
| 328 | } |
| 329 | return unescape(text.toString().replace(/%2B/g, '+')); |
| 330 | } |
| 331 | |
| 332 | // ─── 安全的 safeStringify(保留 BigInt 精度)────────────── |
| 333 | export function safeStringify(obj, space) { |