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

WBOY
Release: 2016-07-13 10:55:46
Original
936 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...
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