Mobile app version of vmapp.org
Login or Join
Kevin317

: After change to new software stack, Chinese pages require setting encoding in browser We changed to a new server with a completely upgraded software stack, including apache 2.4 and php 5.6.9.

@Kevin317

Posted in: #Browsers #ContentEncoding #Html

We changed to a new server with a completely upgraded software stack, including apache 2.4 and php 5.6.9. We have a page in Simplified Chinese. On our old server (apache 2.2, php 5.3.5), the pages just rendered properly. The site is in UTF-8 in most ways, except that the page in question has the following tags:

<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb18030" />


From the new site, the page does not render properly unless the browser encoding is changed for that page. For Chrome, Firefox and IE, the setting change is similar: View > Encoding > gb18030 (on Firefox, Chinese, Simplified).

What is causing the new setup to require this override in the browser, which was never previously required?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Kevin317

1 Comments

Sorted by latest first Latest Oldest Best

 

@Kevin317

We tried lots of things but finally got something to work. We have to send a header before sending any other output. Thus the cause proposed by Simon Hayter is correct, and our solution implements the correction.

Here is what the first two lines or our code looks like:

<?php
header('Content-Type:text/html;charset=gb18030');


We believe the root cause is that the default action for apache changed between version 2.2 and 2.4, which was part of our stack upgrade. Apparently version 2.4 sets the default charset to UTF-8 in the header, and nothing we tried (of many apache configuration options) was able to change that. No matter what we tried, 2.4 sent the following header:

Content-Type: text/html; charset=UTF-8


On the other hand, our apache 2.2 was sending the following header:

Content-Type: text/html


There were no other significant difference in the server output (which was obtained via curl).

As I said, we could not get the apache 2.4 to not send the charset=UTF-8, even with using AddDefaultCharset, etc.

So the workaround is to have php send a header as shown above.

I am attaching an image of part of a diff, showing what I am talking about.The difference marked "17" shows the difference.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme