MCPcopy Create free account
hub / github.com/anus-dev/ANUS / getCachedEncodingForBuffer

Function getCachedEncodingForBuffer

packages/core/src/utils/systemEncoding.ts:30–43  ·  view source on GitHub ↗
(buffer: Buffer)

Source from the content-addressed store, hash-verified

28 * @param buffer A buffer to use for detecting encoding if system detection fails.
29 */
30export function getCachedEncodingForBuffer(buffer: Buffer): string {
31 // Cache system encoding detection since it's system-wide
32 if (cachedSystemEncoding === undefined) {
33 cachedSystemEncoding = getSystemEncoding();
34 }
35
36 // If we have a cached system encoding, use it
37 if (cachedSystemEncoding) {
38 return cachedSystemEncoding;
39 }
40
41 // Otherwise, detect from this specific buffer (don't cache this result)
42 return detectEncodingFromBuffer(buffer) || 'utf-8';
43}
44
45/**
46 * Detects the system encoding based on the platform.

Callers 2

handleOutputMethod · 0.85

Calls 2

getSystemEncodingFunction · 0.85
detectEncodingFromBufferFunction · 0.85

Tested by

no test coverage detected