Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Character Encoding in iframes

I have a text file encoded in ISO-8859-1. If you view it in Google Chrome, it displays correctly. However, if you iframe it, it looks wrong. Also, it always looks wrong in Firefox.

I have noticed this same behavior with various different servers and browsers. However, if I use Google Chrome and run the server and browser on the same machine, the iframe's content displays correctly.

What should I do to make the file show up correctly in all situations? It seems like the browser should be able to figure it out, but in many situations it fails to do so.

like image 547
Nick Retallack Avatar asked Oct 26 '25 00:10

Nick Retallack


1 Answers

You’re serving the file with Content-Type: text/plain, which amounts to asking the browser to guess. Evidently, not every situation results in the same guess.

Set it to Content-Type: text/plain; charset=iso-8859-1.

like image 110
Josh Lee Avatar answered Oct 28 '25 19:10

Josh Lee