PHP generated two-dimensional code Chinese garbled how to do _php tutorial

Source: Internet
Author: User
Tags vcard
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 ...

  • 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.