I am reading a TXT file in my Angular application. This TXT file contains some characters in UTF-8, such as "Prénom annuaire".
When I read this file and print data in console it displays as "Pr�nom annuaire". I am bit confused of this behavior, Below is my code to read the data:
let reader = new FileReader();
reader.onloadend = function (){}
reader.readAsText(evt.target.files[0], "UTF-8");
Can anyone help, How can I read data in UTF-8.
Edit: 1
When I compare strings in my application, "Pr�nom annuaire" and "Prénom annuaire" shows as two different strings.
Edit: 2
Problem i am facing because of this behavior,
I have a JSON object fetched from server as below:
{"First_Name": "Prénom annuaire",...}
Then, I read the TXT file as mentioned above, and each Text I read from the file I need to fetch the respective Key from the above JSON. So when I read the 'Prénom annuaire' from the TXT file, I should compare in the above JSON for this value and It should return the "First_Name" back to me.
But When I compare 'Prénom annuaire' text read from the file with the JSON, I am unable to get respective KEY i.e. 'First_Name'. So When I debug, the Text which read from TEXT file shows as 'Pr�nom annuaire' and couldn't match to the 'Prénom annuaire'.
So, how could I do this comparison?