Encoding & BOM
DenoTS
cited
open
Deno @std/csv CsvParseStream leaves a BOM glued to the first header key
CsvParseStream leaves a leading BOM glued to the first header key
@std/csv · denoland/std
Symptom
The synchronous parse() strips a leading UTF-8 byte-order mark (U+FEFF) but CsvParseStream does not. When a CSV begins with a BOM, common output from Excel and other Windows tools, the first field name arrives as "\uFEFFname" instead of "name", silently corrupting header-based lookups.
Minimal repro
const src = ReadableStream.from(['\uFEFFname,age\n', 'Alice,34\n']);
await Array.fromAsync(src.pipeThrough(new CsvParseStream({ skipFirstRow: true })));
// [{ '\uFEFFname': 'Alice', age: '34' }] <- BOM leaked into the key
Fix
Strip the BOM from the first line read by StreamLineReader, matching what parse() already does via its BYTE_ORDER_MARK constant.