Solutions to blank spaces when browsing UTF-8 encoded web pages_PHP Tutorial

WBOY
Release: 2016-07-13 17:29:45
Original
1046 people have browsed it

One aspect is the server solution:

Apache settings: AddDefaultCharset UTF-8

On another aspect, see the following incident, which I have also encountered:

UTF-8 web pages were allowed to be accessed by others. As a result, many people said that they went blank after entering. It was found that the browser did not automatically select UTF-8 text encoding.

When using IE as the browser on Windows operating system. This problem often occurs: when browsing a webpage using UTF-8 encoding, the browser cannot automatically detect (that is, when the "automatic selection" encoding format is not set) the encoding used by the page. Even if the web page has declared the encoding format:

CODE:

This causes some pages containing Chinese UTF-8 encoding to produce blank output.

If you are using Mozilla, Mozilla Firefox, or Sarafi browsers, this will not cause this problem. This is because when IE parses webpage encoding, it prioritizes tags in HTML, and then information in HTTP headers; while the Mozilla series of browsers do just the opposite.

Since UTF-8 uses 3 bytes to represent one Chinese character, ordinary GB2312 or BIG5 uses two. When the page is output, due to the above reasons, when the browser parses and outputs the content, if there are an odd number of full-width characters in front of it, IE will treat UTF-8 as two bytes when parsing, and half a Chinese character will appear. At this time, This half Chinese character will be combined with < to form a garbled word, causing IE to be unable to finish reading.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/531657.htmlTechArticleOne aspect is the server solution: Apache settings: AddDefaultCharset UTF-8 Another aspect, see the following incident, I also encountered it Passed: The UTF-8 webpage was allowed to be accessed by others, and as a result, many people...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template