Php version WeChat public platform reply garbled problem solution

Source: Internet
Author: User
The public has encountered garbled Chinese characters during development. This issue was found to be a coding problem. In fact, you only need to convert the code into utf8 to solve it. let's take a look at it for details. Many public platforms use ThinkWechat for automatic reply. class. php... the public has encountered garbled Chinese characters during development. This issue was found to be a coding problem. In fact, you only need to convert the code into utf8 to solve it. let's take a look at it for details.

Many automatic reply programs on the public platform are developed based on ThinkWechat. class. php. today, I encountered an inexplicable garbled problem. I found it was caused by GB2312 encoding, so I had to modify the source code.

Add a method first

/*** Check whether the UTF-8 * @ param $ str * @ return bool */private function is_utf8 ($ str) {return preg_match ('// U', $ str );}

Find

$ This-> data ['content'] = $ Content;

Change

If ($ this-> is_utf8 ($ content) {$ this-> data ['content'] = $ Content ;} else {$ this-> data ['content'] = iconv ('gb2312', 'utf-8 // IGNORE ', $ Content );}

You can.

Article URL:

Reprint ^ at will, but please attach the tutorial address.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.