Angular 如何上传CSV并使用UTF-8编码显示?

Angular 如何上传CSV并使用UTF-8编码显示?,angular,Angular,因此,我目前正在与CSV文件上传项目的工作。我可以用console.log记录csv,但它不是UTF-8编码的。我用典型的�其中的符号 这是我的代码块: import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class

因此,我目前正在与CSV文件上传项目的工作。我可以用console.log记录csv,但它不是UTF-8编码的。我用典型的其中的符号

这是我的代码块:

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'testing';
  csv = [];


  public changeListener(files: FileList){


    if(files && files.length > 0) {
       let file : File = files.item(0); 
         console.log(file.name);
         //console.log(file.size);
         console.log(file.type);

         let reader: FileReader = new FileReader();
         reader.readAsText(file, 'UTF-8');
         reader.onload = (e) => {
            let csv: string = reader.result as string;
            console.log("\ufeff" + csv);
         }
      }
  }

}

现在它工作了,我需要改变:

reader.readAsText(file, 'UTF-8');


CSV文件一切正常这只是一个编码问题-我现在可以显示“ä,ü,ö…”

问题似乎在CSV文件中,代码工作正常。检查这里的thx,但它仍然显示umlauts(ä,ö,ü..)� SYMBOLS这帮我搞定了非常感谢!
reader.readAsText(file, 'ISO-8859-1');