Imported as a linear vendor commit so forge rebases do not replay the upstream root tree. git-subtree-dir: third_party/pi git-subtree-split: d981de1229ef899957bbe968bc8dcda02a21f477
10 lines
404 B
TypeScript
10 lines
404 B
TypeScript
/** Split a leading UTF-8 byte order mark from decoded text. */
|
|
export function splitBom(content: string): { bom: string; text: string } {
|
|
return content.startsWith("\uFEFF") ? { bom: "\uFEFF", text: content.slice(1) } : { bom: "", text: content };
|
|
}
|
|
|
|
/** Remove a leading UTF-8 byte order mark from decoded text. */
|
|
export function stripBom(content: string): string {
|
|
return splitBom(content).text;
|
|
}
|