Nick Retallack
Nick Retallack

Reputation: 19561

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.

Upvotes: 4

Views: 10145

Answers (1)

Josh Lee
Josh Lee

Reputation: 177594

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.

Upvotes: 5

Related Questions