Error: Spanish character is imported wrongly.
The text file contains Spanish and English characters.
*.txt
Jose Nuñez,David Gutiérrez,Rocío Moreno,César Millones .....
Output after import to the server
Jose Nuñez,David Gutiérrez,RocÃo Moreno ....
*.ts
onFileChange(event: any) {
const target: DataTransfer = <DataTransfer>(event.target);
if (target.files.length !== 1) throw new Error('Cannot use multiple files');
if (target.files.length !== 1 && event.target.accept !== ".txt") throw new Error('Cannot use multiple files');
this.uploadedFileName = target.files[0].name;
if (target.files.length == 1 && (target.files[0].type == ".txt" || target.files[0].type == "text/plain")) {
this.uploadedFileName = event.target.files[0].name;
if (event.target.files.length > 0) {
const file = event.target.files[0];
this.tFileList = event.target.files[0];
this.searchFilterForm.get('edt').setValue(file);
}
}
else {
this.processErrorDetails = "Please select .txt file only!";
}
}
Service
public Import(body: any, observe: any = 'body', reportProgress: boolean = false): Observable < any > {
let headers = this.defaultHeaders;
headers.append('Content-Type', 'text/plain');
return this.httpClient.post<any>(`${this.URL}/import_files`,
body,
{
observe: 'response'
, headers: headers
}
);
}