0

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?

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0
<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.

2 Comments

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: 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.