dart-lang / core

This repository is home to core Dart packages.
https://pub.dev/publishers/dart.dev
BSD 3-Clause "New" or "Revised" License
17 stars 4 forks source link

please add cp-850 and Windows1252 support #279

Open insinfo opened 2 years ago

insinfo commented 2 years ago

please add cp-850 and Windows1252 support

for decoding text in excel MS DOS CSV sheets


void main(List<String> args) async {
  final input = new File( 'C:/MyDartProjects/notifis/notifis_backend/db/planilhas/CIP 2012.csv').openRead();

  final codec = const Windows1252Codec(allowInvalid: false);
  final stream = await input.transform(codec).transform(LineSplitter());
  await for (var lineString in stream) {
    var rowsAsListOfValues =
        CsvToListConverter(fieldDelimiter: ';').convert(lineString);
    var lineCsv = rowsAsListOfValues.first;
    print(lineCsv.map((e) => '$e').join(' | '));
  }

  exit(0);
}
devoncarew commented 2 years ago

Thanks for the request and the example!