Skip to content
1 min read · 172 words

Function: psSingleQuotedLiteral() ​

ts
function psSingleQuotedLiteral(s: string): string;

Defined in: src/batteries/tts/native/helpers.ts:44

Encode s as a single-quoted PowerShell string literal: wrap in single quotes and double every internal single quote (' → ''). PowerShell single-quoted literals are verbatim — no variable interpolation, no escape sequences — so this is the only quoting rule needed.

Parameters ​

ParameterTypeDescription
sstringThe string to quote. Must be a finite string.

Returns ​

string

The single-quoted PowerShell literal of s.

Remarks ​

Before quoting, NUL and all C0/Cc control characters are stripped (and a stray NUL rejected) so an adversarial text/voice/outPath cannot inject a control character that PowerShell or the underlying console might interpret. This is a defensive guard, not a complete PowerShell fuzzer: it rejects the byte values that are unsafe inside ANY string context (NUL and control codes), and lets everything else through verbatim inside the single-quoted literal.

Throws ​

when s is not a string or contains a NUL byte (\0).