0

I have a csv file which contains some German Words. I want to convert them to UTF-8.

Below is my code:

 Widget build(BuildContext context, ) {
    return FutureBuilder<String>(
        future: rootBundle.loadString('assets/questions.csv'),
        builder: (BuildContext context, AsyncSnapshot<String> snapshot,) {
        List<List<dynamic>>  csvTable =
          CsvToListConverter().convert(snapshot.data);
          print(csvTable);

This is how my csv is looking now. It is not displaying German Words.

This is what i my csv is looking now. It is not displaying German Words

u2k
  • 37
  • 2
  • There is no way that you can create an effective converter. Your best chance is to try loading the file with 1252, or even better to ask the one creating it to do it with UTF-8, as there is not one good reason it should otherwise. – Slobodan Antonijević Apr 01 '21 at 16:02
  • Thanks Slobodan for your time. There is no issue in the csv file itself, it is displaying the characters normally and encoding is also set to utf-8. But when i load it in the flutter project it does not show proper words. I tried 1252, but it displays nothing rather give some error relating to index. – u2k Apr 02 '21 at 19:06

1 Answers1

0

You need to convert your csv to utf-8 first, as excel does not convert it despite it shows formatting as utf-8 (That's were i got confused, as i was sure that my csv is utf-8, but actually it was not). The answer is in below link :

Excel to CSV with UTF8 encoding

The method which work for me was:

Open Google Sheet and

1-On the main Docs (or Drive) screen click the "Create" button and choose "Spreadsheet" 2-From the "File" menu choose "Import" 3-Click "Choose File" 4-Choose "Replace spreadsheet" 5-Choose whichever character you are using as a Separator 6-Click "Import" 7-From the "File" menu choose "Download as" -> CSV (current sheet)

The resulting file will be in UTF-8

u2k
  • 37
  • 2