* 解码 Instagram 特殊编码的文本 * Instagram 将 UTF-8 字节按 Latin-1 编码后存储
(text: string)
| 111 | * Instagram 将 UTF-8 字节按 Latin-1 编码后存储 |
| 112 | */ |
| 113 | function decodeInstagramText(text: string): string { |
| 114 | try { |
| 115 | // 将每个字符的 charCode 收集为字节数组 |
| 116 | const bytes = new Uint8Array(text.length) |
| 117 | for (let i = 0; i < text.length; i++) { |
| 118 | bytes[i] = text.charCodeAt(i) |
| 119 | } |
| 120 | // 用 UTF-8 解码 |
| 121 | return new TextDecoder('utf-8').decode(bytes) |
| 122 | } catch { |
| 123 | return text // 解码失败则返回原文 |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * 从文件名提取名称(备用) |
no outgoing calls
no test coverage detected