Method 2,
Returns a string, all non-letters in this string except -_. Numeric characters will be replaced with a percent sign (%) followed by two hexadecimal digits. To decode: rawurldecode Method 3, gbk version: In gbk encoding, a Chinese character consists of two characters. If the ascii value of the character obtained through the ord() function is greater than 127, it can be determined that the current character is the first half of a Chinese character, and the second half of the Chinese character needs to be obtained. Of course, this method of judgment must be combined with the specific development environment. If there is a single character with an ascii value greater than 127, this method of judgment is obviously incorrect. The principle of converting Chinese characters to decimal in PHP is to obtain the two characters of a Chinese character through the for loop method, and then use the ord() function to convert each character into decimal. The above are respectively: No [178 187] Want [210 170] Fan [195 212] Love [193 181] Brother [184 231] PHP implements the principle of converting Chinese characters to hexadecimal: First, use the ord() function to get the decimal number of each Chinese character. For details, please see [php function article to master the application of ord() and chr() functions], and then use the dechex() function to convert each Chinese character into hexadecimal. Code:
utf-8 version:
|