We break down how to bring text from a file into a predictable form before parsing: read data as
ByteArray, remove the UTF‑8
BOM by its signature
EF BB BF, decode via
Charsets.UTF_8, normalize line breaks (
"\r\n",
"\n",
"\r"), and assemble everything into a
readCleanUtf8() function so the parser works only with “clean” input.