Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of Chinese garbled codes in gbk and gb2312 handled by json_encode in php

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

The content of this article mainly explains "how to solve the Chinese garbled code of json_encode in php dealing with gbk and gb2312". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "how to solve the Chinese garbled code of gbk and gb2312 in json_encode in php"!

This paper describes the solution of json_encode in php to deal with the problem of garbled codes in gbk and gb2312. The specific methods are as follows:

1.json_encode () Chinese is returned as null for Chinese in gbk/gb2312

$arr = array (array ('catid' = >' 44th, 'catname' = >' www.jb51.net', 'meta_title' = >''); echo json_encode ($arr)

Running result:

[{"catid": "4", "catname": "www.jb51.net", "meta_title": null}]

Have you seen "meta_title": null, he used to have a value of "". We checked that the principle is that json_encode only supports uft-8 encoding. Let's convert it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report