MCPcopy Create free account
hub / github.com/codeHappyDananx/SpecWave / decodeTextBuffer

Function decodeTextBuffer

electron/main.js:650–662  ·  view source on GitHub ↗
(buffer)

Source from the content-addressed store, hash-verified

648}
649
650function decodeTextBuffer(buffer) {
651 const meta = detectTextMeta(buffer)
652 const body = buffer.slice(meta.bomLength)
653 if (meta.encoding === 'utf16le') {
654 return { text: body.toString('utf16le'), meta }
655 }
656 if (meta.encoding === 'utf16be') {
657 const swapped = Buffer.from(body)
658 if (swapped.length >= 2) swapped.swap16()
659 return { text: swapped.toString('utf16le'), meta }
660 }
661 return { text: body.toString('utf8'), meta }
662}
663
664function detectEol(text) {
665 if (typeof text !== 'string' || text.length === 0) return '\n'

Callers 1

main.jsFile · 0.85

Calls 1

detectTextMetaFunction · 0.85

Tested by

no test coverage detected