I have no idea what the issue is, I am completely new in Angular. I am trying to read a local .csv file and write it's contents into a table. All that works, except for the fact that all my special characters - "č, ć, š, ž"... are turned into �. The text from the .csv file arrives to the next .ts file already messed up so my guess is that something here is wrong.
This is my code:
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
@Injectable({
providedIn: 'root'
})
export class CSVService {
csvPath = "podaci.csv";
constructor(private http: HttpClient) { }
getUserData() {
const headers = new HttpHeaders({'Content-Type':'text; charset=UTF-8'});
return this.http.get(this.csvPath, {responseType: 'text',headers});
}
}
And this is what I see in the inspector - Network:
Response headers:
Accept-Ranges: bytes
Access-Control-Allow-Origin: *
Content-Length: 166
Content-Type: text/csv; charset=UTF-8
Date: Thu, 11 Jun 2020 18:06:51 GMT
ETag: W/"a6-LoPGiIg9Tq/YkFbUjQBkFcVvZCg"
X-Powered-By: Express
Request Headers:
Accept: application/json, text/plain, */*
Accept-Encoding: gzip, deflate, br
Accept-Language: hr-HR,hr;q=0.9,en-US;q=0.8,en;q=0.7,it;q=0.6
Connection: keep-alive
Content-Type: text; charset=UTF-8
Host: localhost:4200
If-None-Match: W/"a6-LoPGiIg9Tq/YkFbUjQBkFcVvZCg"
Referer: http://localhost:4200/
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36
I tried placing different types of charset headers but it always looks the same.. Sorry if I missed any info, I would appreciate if somebody explained this to me.. thank you