PHP generated two-dimensional code Chinese garbled what to do
Recently made a scan QR code to get a vcard project, encountered a problem, there is a part of the generated QR code, the Android phone scan to get a vcard in the Chinese name is garbled, after comparison to find, this part of the vcard in the type of org is not content, Immediately judge no content to add a fixed string, so the problem of garbled can be resolved. Such a solution is a curve to the salvation of the bar, do not know how to solve the problem of garbled, who get the method please leave a message to inform, thank you.
Third, PHP generation of two-dimensional code of several ways
1.google Open API
The code is as follows |
|
$urlToEncode = "http://gz.altmi.com"; Generateqrfromgoogle ($urlToEncode); function Generateqrfromgoogle ($chl, $widhtHeight = ' Max ', $EC _level= ' L ', $margin = ' 0 ') { $url = UrlEncode ($url); Echo '; } |
2.php class library PHP QR Code
Address: http://phpqrcode.sourceforge.net/
Download: http://sourceforge.net/projects/phpqrcode/
Case:
code as follows |
|
# Create a QR code file QRCode::p ng (' Code data text ', ' filename.png '); # generate picture to browser QRCode::p ng (' some Othertext 1234 '); |
3.libqrencode
Address: http://fukuchi.org/works/qrencode/index.en.html
PHP support please refer to: http://hirokawa.netflowers.jp/entry/4900/
4.QRcode Perl CGI & PHP Tutorial Scripts
Address: http://www.swetake.com/qr/qr_cgi.html
Four, the 2nd method in the two-dimensional code in the middle of the logo
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 = i Magecreatefrompng ($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); } |
http://www.bkjia.com/PHPjc/827289.html www.bkjia.com true http://www.bkjia.com/PHPjc/827289.html techarticle PHP generated two-dimensional code Chinese garbled what to do recently did a scan QR code to get a vcard project, encountered a problem, there is a part of the generation of the two-dimensional code, the Android phone after scanning ...