Home>Article>Backend Development> Detailed analysis of URL encoding issues containing Chinese characters

Detailed analysis of URL encoding issues containing Chinese characters

黄舟
黄舟 Original
2017-03-06 16:40:51 1601browse

In xml applications, some URL information is often stored as xml data, and the URL parameters may contain Chinese characters. When using dom to parse xml data, Chinese characters can be encoded.
But if you only use xslt to display xml data (data.xml+data.xsl), you will find that the URL will have an encoding error. Even if you specify the encoding type (encoding="gb2312"), the same error will still occur. Problem.
The test found that it is a problem with IE’s caching mechanism. IE will still default the MIME content type of the new page (linked URL) to text/xml

Solution:
1 .Specify the output document type as xml document (example:data.xsl)

2. Open in a new window, add attributes to the connection, and specify that the target window is another window (example:data2.xsl )

       
        _blank
       examples: /*** data.xml ***/
       
       
       
        
         
          http://www.google.com/search?q=
         
         
          xml数据
         
        
        
         
          http://www1.baidu.com/baidu?word=
         
         
          xml数据
         
        
        
         
          http://www.google.com/search?q=
         
         
          极限编程(xp)
         
        
        
         
          http://www1.baidu.com/baidu?word=
         
         
          极限编程(xp)
         
        
       /*** data.xsl ***/
       
       
        
        
         
        
        
         
          
           
           
          
          
         
         
/*** data2.xsl ***/ _blank

The above is a detailed analysis of URL encoding issues containing Chinese characters. For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!


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