(str)
| 391 | |
| 392 | // ─── 字符串字节数(替代 String.prototype.getBytes 的纯函数版本)── |
| 393 | export 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 防护)──────────────────────────────── |
| 400 | export function createSafeToastHTML(content) { |