dart-lang / convert

Conversion utilities
https://pub.dev/packages/convert
BSD 3-Clause "New" or "Revised" License
71 stars 25 forks source link

please add cp-850 and Windows1252 support #64

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!