PHP generated two-dimensional code Chinese garbled how to do

Source: Internet
Author: User
Tags php class vcard

Recently done a scan two-dimensional code to get a vcard project, encountered a problem, a part of the generated two-dimensional code, using the Android phone after scanning the Chinese name of the vcard is garbled, after the discovery, this part of the vcard org this type has no content, Immediately judged no content to add a fixed string, so garbled problem can be solved. This solution is a curve to save the nation, do not know how to solve the garbled problem, who get the method please leave a message, thank you.

Three, PHP generation of two-dimensional code several ways

1.google Open API

The code is as follows

$urlToEncode = "http://gz.altmi.com";
Generateqrfromgoogle ($urlToEncode);
function Generateqrfromgoogle ($chl, $widhtHeight = ' _level= ', $EC ' 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:

The code is as follows

# Create a two-dimensional code file
QRCode::p ng (' Code data text ', ' filename.png ');
# Generate pictures 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 Tutorials Scripts

Address: http://www.swetake.com/qr/qr_cgi.html

The 2nd method is to add a logo in the middle of the two-dimensional code.

To modify the PNG method in the Qrimage class in phpqrcode.php:

  code is as follows &nbs P;

public static function png ($frame, $filename = False, $pixelPerPoi NT = 4, $outerFrame = 4, $saveandprint =false, $mergePic = ')
{
$image = Self::image ($frame, $pixelPerPoint, $outerF Rame);
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);
}

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.