Home Backend Development XML/RSS Tutorial Detailed analysis of URL encoding issues containing Chinese characters

Detailed analysis of URL encoding issues containing Chinese characters

Mar 06, 2017 pm 04:40 PM

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)

<xsl:output method="xml"  encoding="gb2312" media-type="text/xml" />
Copy after login

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 ***/



<xsl:output method="xml"  encoding="gb2312" media-type="text/xml" />

   


 
  
  
 
 
/*** data2.xsl ***/ _blank
Copy after login

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 (www.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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to deal with the pinyin sorting problem of Chinese characters in PHP? How to deal with the pinyin sorting problem of Chinese characters in PHP? Sep 05, 2023 pm 05:00 PM

How to deal with the pinyin sorting problem of Chinese characters in PHP? When developing Chinese websites or applications, we often face the need to sort Chinese strings according to pinyin. However, due to the complexity of Chinese characters, directly using conventional sorting algorithms will lead to errors in sorting results. Therefore, we need to use a special method to deal with the pinyin sorting problem of Chinese characters. In PHP, a common solution is to use a pinyin library such as "Overtrue/Pinyin". This is a pinyin based on PHP

How to solve URL decoding exceptions in Java development How to solve URL decoding exceptions in Java development Jun 29, 2023 pm 02:07 PM

How to solve URL decoding exceptions in Java development. In Java development, we often encounter situations where URLs need to be decoded. However, due to different encoding methods or non-standard URL strings, URL decoding abnormalities sometimes occur. This article will introduce some common URL decoding exceptions and corresponding solutions. 1. The cause of URL decoding exception is mismatch in encoding methods: special characters in the URL need to be URL encoded, that is, converted into hexadecimal values ​​starting with %. When decoding, you need to use

How to verify whether the input is all Chinese characters in golang How to verify whether the input is all Chinese characters in golang Jun 24, 2023 am 09:16 AM

With the development of the times, we pay more and more attention to the verification of data, especially the verification of user input. For language verification, how to accurately determine whether the input is all Chinese characters has become an important issue. In golang, we can use the unicode package and regexp package to achieve this requirement. 1. Unicode package The unicode package provides a series of core support for Unicode. We can use the functions in this package to accurately determine whether a character is a Chinese character.

How to sort Chinese characters in C language environment? How to sort Chinese characters in C language environment? Feb 18, 2024 pm 02:10 PM

How to implement Chinese character sorting function in C language programming software? In modern society, the Chinese character sorting function is one of the essential functions in many software. Whether in word processing software, search engines or database systems, Chinese characters need to be sorted to better display and process Chinese text data. In C language programming, how to implement the Chinese character sorting function? One method is briefly introduced below. First of all, in order to implement the Chinese character sorting function in C language, we need to use the string comparison function. Ran

How to use the urllib.parse.quote() function to encode URLs in Python 3.x How to use the urllib.parse.quote() function to encode URLs in Python 3.x Jul 31, 2023 pm 10:46 PM

Use the urllib.parse.quote() function to encode URLs in Python3. Parameters may contain special characters. The urllib.parse module in Python provides the quote() function, which can encode illegal characters in URLs into legal URL strings. This article will be passed through

How to utilize PHP functions for URL encoding and decoding? How to utilize PHP functions for URL encoding and decoding? Jul 24, 2023 pm 11:21 PM

How to utilize PHP functions for URL encoding and decoding? In PHP, URL encoding and decoding are very common operations. URL encoding converts special characters in the URL into corresponding encoded values. Common special characters include spaces, slashes, question marks, etc. URL decoding converts the encoded value back to the original special characters. PHP provides a series of functions to implement URL encoding and decoding functions. This article will introduce the commonly used urlencode() and urldecode() functions and give corresponding code examples.

How to use regular expressions to match Chinese characters in PHP How to use regular expressions to match Chinese characters in PHP Jun 22, 2023 am 09:16 AM

In PHP, regular expression is a commonly used string matching tool. It can be used to determine whether a string conforms to a specific format, thereby verifying the validity of the input value. When processing Chinese characters, since Chinese characters and English characters are encoded differently, the matching rules of the regular expression need to be adjusted accordingly. This article will introduce how to use regular expressions to match Chinese characters in PHP. 1. Understand Chinese character encoding. Commonly used character encodings in PHP are UTF-8 and G.

How to use the urllib.parse.urlencode() function to encode parameters in Python 3.x How to use the urllib.parse.urlencode() function to encode parameters in Python 3.x Aug 03, 2023 pm 03:18 PM

How to use the urllib.parse.urlencode() function to encode parameters in Python3.x. When performing network programming or making HTTP requests, it is often necessary to encode the parameters in the URL. The urllib module in Python provides the convenient urlencode() function to encode URL parameters. This article will introduce how to use the urllib.parse.urlencode() function in Python3.x

See all articles