views:

707

answers:

2

Hi,
I have an a.js file written in windows-1251 charset.
Now, I have a b.php script, that has

header('Content-Type: text/html; charset=windows-1251');

in it. It also includes the a.js somewhere in the template.
So I'm loading b.php into c.php (also headered that way) using jQuery.load. What I get is ??? instead of normal words in the place where content is generated by js file. What is wrong?

A: 
<meta http-equiv="content-type" content="text/html; charset=windows-1251" />

at the top of the page affects this, the page you load in normal manner.

Vasil
In other words, if you have a "content-type" meta tag the HTML being produced, it may be overriding the Content-type header that PHP is sending. If so, either remove the meta tag or change it to match the header.
Ben Blank
@Ben: the HTTP header takes precedence over the meta tag; the setting in the meta tag only gets applied if the server doesn't send an encoding
Christoph
+1  A: 

The header() statement only applies to PHP output, and when your browser pulls the .js file it may treat it differently.

Are you able to edit that .js file and save it with other frequently used encoding (such as utf-8 or iso-8859-1)? There are many free editors that can load/save in different encodings. That might help.

Seb