MCPcopy Create free account
hub / github.com/anomalyco/opencode / decodeUtf8

Function decodeUtf8

packages/core/src/tool/edit.ts:50–53  ·  view source on GitHub ↗
(content: Uint8Array)

Source from the content-addressed store, hash-verified

48 text.startsWith("\uFEFF") ? { bom: true, text: text.slice(1) } : { bom: false, text }
49const joinBom = (text: string, bom: boolean) => (bom ? `\uFEFF${text}` : text)
50const decodeUtf8 = (content: Uint8Array) => {
51 const bom = content[0] === 0xef && content[1] === 0xbb && content[2] === 0xbf
52 return { bom, content, text: new TextDecoder().decode(bom ? content.slice(3) : content) }
53}
54
55const countOccurrences = (content: string, search: string) => {
56 if (search === "") return content.length + 1

Callers 1

edit.tsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected