Php solves Chinese garbled characters when generating QR codes ,. The solution to Chinese garbled characters occurs when php generates a QR code. this example describes how to solve Chinese garbled characters when php generates a QR code. Share it with you for your reference. For details, see the solution to Chinese garbled characters when php generates a QR code,
This example describes how to solve Chinese garbled characters when php generates a QR code. Share it with you for your reference. The specific analysis is as follows:
Recently, I had a project to scan the QR code to get the vcard. I encountered a problem. some of the generated QR codes were garbled in the Chinese names in the vcard obtained after scanning with the android mobile phone, after comparison, we found that there is no content in the ORG type in this part of vcard, and a fixed string is added when no content is determined, so that the garbled problem can be solved.
Php QR code generation methods
1. open the api on google with the following code:
The code is as follows:
$ UrlToEncode = "http://www.bkjia.com ";
GenerateQRfromGoogle ($ urlToEncode );
Function generateQRfromGoogle ($ chlorophyll, $ widhtHeight = '000000', $ EC_level = 'l', $ margin = '0 ')
{
$ Url = urlencode ($ url );
Echo '';
}
2. php QR Code Library
Address: http://phpqrcode.sourceforge.net/
Download: http://sourceforge.net/projects/phpqrcode/
The code is as follows:
# Create a QR code file
The code is as follows:
QRcode: png ('code data text', 'filename.png ');
# Generating images to the browser
The code is as follows:
QRcode: png ('Some othertext 1234 ');
3. libqrencode
Address: http://fukuchi.org/works/qrencode/index.en.html
4. QRcode Perl CGI & PHP scripts
Address: http://www.swetake.com/qr/qr_cgi.html
Add a logo in the middle of the QR code in the 2nd methods and modify the png method in the QRimage class in phpqrcode. php. the code is as follows:
The code is as follows:
Public static function png ($ frame, $ filename = false, $ pixelPerPoint = 4, $ outerFrame = 4, $ saveandprint = FALSE, $ mergePic = '')
{
$ Image = self: image ($ frame, $ pixelPerPoint, $ outerFrame );
If ($ mergePic ){
$ Im = imagecreatefrompng ($ mergePic );
$ W = imagesx ($ im );
$ H = imagesy ($ im );
ImageAlphaBlending ($ image, true );
ImageAlphaBlending ($ im, true );
$ Qrw = (imagesx ($ image)-$ w)/2;
$ Qrh = (imagesy ($ image)-$ h)/2;
Imagecopy ($ image, $ im, $ qrw, $ qrh, 0, 0, $ w, $ h );
Imagedestroy ($ im );
}
If ($ filename = false ){
Header ("Content-type: image/png ");
ImagePng ($ image );
} Else {
ImagePng ($ image, $ filename );
If ($ saveandprint === TRUE ){
Header ("Content-type: image/png ");
ImagePng ($ image );
}
}
ImageDestroy ($ image );
}
I hope this article will help you with PHP programming.
Example: How to solve Chinese garbled characters when a QR code is generated by php. Share it with you for your reference. The specific analysis is as follows...