MCPcopy Create free account
hub / github.com/zxlie/FeHelper / uniDecode

Function uniDecode

apps/json-format/json-utils.js:318–330  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

316}
317
318export 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 精度)──────────────
333export function safeStringify(obj, space) {

Callers 1

json-utils.test.jsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected