MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / decodeInstagramText

Function decodeInstagramText

packages/parser/src/formats/instagram-native.ts:113–125  ·  view source on GitHub ↗

* 解码 Instagram 特殊编码的文本 * Instagram 将 UTF-8 字节按 Latin-1 编码后存储

(text: string)

Source from the content-addressed store, hash-verified

111 * Instagram 将 UTF-8 字节按 Latin-1 编码后存储
112 */
113function 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 * 从文件名提取名称(备用)

Callers 2

getMessageContentFunction · 0.85
parseInstagramFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected