1

I'm trying to read a file formated as UTF-16 LE

new File(filePath)
        .openRead()
        .map(utf8.decode)
        .transform(new LineSplitter())
        .forEach((l) => print('line: $l'));

But I get this error Unhandled Exception: FormatException: Invalid UTF-8 byte I've also tried to use this package utf: ^0.9.0+5 but it's not an option cause of null safety. Any ideas? Thanks

Heero Yuy
  • 614
  • 9
  • 24
  • 2
    `utf8.decode` decodes UTF-8 data, so it doesn't make sense to use it on UTF-16LE data. See https://stackoverflow.com/a/67802971/ for a way to read a UTF-16LE file as a `String`. – jamesdlin Jun 02 '21 at 10:05
  • thanks for the link, i'm able to read it now – Heero Yuy Jun 02 '21 at 10:27

0 Answers0