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

Function getStringBytes

apps/json-format/json-utils.js:393–397  ·  view source on GitHub ↗
(str)

Source from the content-addressed store, hash-verified

391
392// ─── 字符串字节数(替代 String.prototype.getBytes 的纯函数版本)──
393export function getStringBytes(str) {
394 const stream = str.replace(/\n/g, 'xx').replace(/\t/g, 'x');
395 const escaped = encodeURIComponent(stream);
396 return escaped.replace(/%[A-Z0-9][A-Z0-9]/g, 'x').length;
397}
398
399// ─── toast 安全版(XSS 防护)────────────────────────────────
400export function createSafeToastHTML(content) {

Callers 1

json-utils.test.jsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected