Home > Backend Development > PHP Tutorial > Quick and simple solution to php+jquery+json Chinese garbled characters_PHP tutorial

Quick and simple solution to php+jquery+json Chinese garbled characters_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:55:46
Original
965 people have browsed it

Today we used regular expressions to determine preg_replace replacement, such as \u5c71\u4e1c, which is escaped by jquery, but sometimes Chinese problems still occur. Let’s take a look at the solution

 代码如下 复制代码
$code = json_encode($str);
$code = preg_replace("#u([0-9a-f]+)#ie", "iconv('UCS-2', 'UTF-8', pack('H4', '1'))", $code);
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632225.htmlTechArticleToday we used regular expressions to determine preg_replace replacement, such as \u5c71\u4e1c escaped by jquery, but Sometimes Chinese language problems still occur, let’s take a look at the solutions...
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
Latest Issues
Return JSON from PHP script
From 1970-01-01 08:00:00
0
0
0
How to convert json string to json object in php
From 1970-01-01 08:00:00
0
0
0
Extract and access JSON data using PHP
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template