MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / toUtf16LeBase64

Function toUtf16LeBase64

source code/utils/powershell/parser.ts:671–682  ·  view source on GitHub ↗

* Base64-encode a string as UTF-16LE, which is the encoding required by * PowerShell's -EncodedCommand parameter.

(text: string)

Source from the content-addressed store, hash-verified

669 * PowerShell's -EncodedCommand parameter.
670 */
671function toUtf16LeBase64(text: string): string {
672 if (typeof Buffer !== 'undefined') {
673 return Buffer.from(text, 'utf16le').toString('base64')
674 }
675 // Fallback for non-Node environments
676 const bytes: number[] = []
677 for (let i = 0; i < text.length; i++) {
678 const code = text.charCodeAt(i)
679 bytes.push(code & 0xff, (code >> 8) & 0xff)
680 }
681 return btoa(bytes.map(b => String.fromCharCode(b)).join(''))
682}
683
684/**
685 * Build the full PowerShell script that parses a command.

Callers 1

Calls 1

toStringMethod · 0.65

Tested by

no test coverage detected