0

I am trying to read/get data from URL of text file as below. It gives proper data when txt file encoding is UTF-8 but when encoding type is ANSI, it is showing � for ” curly quotes.

    let url='www.test.com/test.txt';
    return this.http.get(url, { responseType: 'text' });

Can anyone please let me know how I can get data from URL of text file with encoding type ANSI?

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
Darshana
  • 662
  • 1
  • 10
  • 29
  • Is your webserver *serving* the file with the correct Content-Type header…?! If it's served as UTF-8 but actually contains ANSI, well, yes, you'll get encoding problems. – deceze Aug 26 '20 at 10:10
  • @deceze Thanks for the quick reply. Yes there are files with encoding type ANSI and UTF-8 both. So I need to handle in angular to read it's content. Can you suggest any plugin or any other workaround for this case? – Darshana Aug 26 '20 at 11:03
  • @Darshana: your **server** needs to provide the correct content-type header *with* the precise encoding to use to read the file or Angular won't be able to get it right. If your server doesn't **know** the correct encoding for each file, then that's your problem: fix this. Ideally by converting [everything to UTF-8](https://utf8everywhere.org/). – Joachim Sauer Mar 28 '23 at 08:24

0 Answers0