Php generates QR code with Chinese garbled characters
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. This solution is a curve to save the country. I don't know how to solve the garbled code problem. Please leave a message if you can find a solution. Thank you.
3. Several methods for generating QR codes in php
1. Open APIs for google
The Code is as follows: |
|
$ UrlToEncode = "http://gz.altmi.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/
Use Case:
The Code is as follows: |
|
# Create a QR code file QRcode: png ('Code data text', 'filename.png '); # Generating images to the browser QRcode: png ('some othertext 1234 '); |
3. libqrencode
Address: http://fukuchi.org/works/qrencode/index.en.html
Php support see: http://hirokawa.netflowers.jp/entry/4900/
4. QRcode Perl CGI & PHP tutorial scripts
Address: http://www.swetake.com/qr/qr_cgi.html
4. Add a logo in the middle of the QR code in the 2nd Methods
Modify the png method in the QRimage class in phpqrcode. php:
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 ); } |