iPhone does not read accents correctly in QR CODE that works normally on Android

Asked

Viewed 458 times

0

I am generating a QR code from a VCARD using PHP QR Code (http://phpqrcode.sourceforge.net) and works perfectly (taking out a problem while saving in SVG I will search better first).

Anyway, at the moment the problem is that the same QR code works correctly on Android and does not work properly on iPhone.

The problem is accentuation. Strange characters are displayed instead of ç, ã, etc...

Any idea? I’ve researched and can’t find the solution.

<?php 

include('phpqrcode/qrlib.php'); 

// how to build raw content - QRCode with detailed Business Card (VCard) 
$tempDir = ""; 

// here our data 
$name         = 'João Carlos da Silva'; 
$sortName     = 'da Silva;João Carlos'; 
$phone        = '+55 (89) 2345-6789'; 
$phonePrivate = '+55 (94) 4521-3989'; 
$phoneCell    = '+55 (66) 1234-5678'; 
$orgName      = 'GH Construtora'; 

$email        = '[email protected]'; 

// if not used - leave blank! 
$addressLabel     = 'Escritório'; 
$addressPobox     = ''; 
$addressExt       = '2º andar'; 
$addressStreet    = 'Av. das Nações, 200'; 
$addressTown      = 'Cidade'; 
$addressRegion    = 'SP';
$addressPostCode  = '18.902-100'; 
$addressCountry   = 'Brasil'; 

// we building raw data 
$codeContents  = 'BEGIN:VCARD'."\n"; 
$codeContents .= 'VERSION:2.1'."\n"; 
$codeContents .= 'N:'.$sortName."\n"; 
$codeContents .= 'FN:'.$name."\n"; 
$codeContents .= 'ORG:'.$orgName."\n"; 

$codeContents .= 'TEL;WORK;VOICE:'.$phone."\n"; 
$codeContents .= 'TEL;HOME;VOICE:'.$phonePrivate."\n"; 
$codeContents .= 'TEL;TYPE=cell:'.$phoneCell."\n"; 

$codeContents .= 'ADR;TYPE=work;'. 
    'LABEL="'.$addressLabel.'":' 
    .$addressPobox.';' 
    .$addressExt.';' 
    .$addressStreet.';' 
    .$addressTown.';' 
    .$addressPostCode.';' 
    .$addressCountry 
."\n"; 

$codeContents .= 'EMAIL:'.$email."\n"; 

$codeContents .= 'END:VCARD'; 

// generating 
QRcode::png($codeContents, $tempDir.'026.png', QR_ECLEVEL_L, 7); 

// displaying 
echo '<img src="026.png" />';

AndroidiPhone

  • The biggest problem I saw, looking over your link documentation, is that the mentioned Ncoder does not have a config for the user to define which of the various ways to encode special QR characters will be used. And the other problem is that you didn’t mention on the question on which encoding you saved your source code.

  • I didn’t think how to set the encoding inside the API, but the correct one would be to use UTF-8, correct? My file is as UTF-8.

  • If someone knows of another API similar to the one that does not have this problem, I can change without problems since I am still at the beginning of the system development.

1 answer

0


I solved the question. Although it seems to be an encoding problem, it was not because it was already in UTF-8. The problem is actually simpler, this code was taken from the examples page of PHP QR Code, but it arrow the version of VCARD as 2.1 as in the line below. I simply switched to 3.0 and solved my problem on both iOS and Android.

$codeContents .= 'VERSION:2.1'."\n";

Switch to:

$codeContents .= 'VERSION:3.0'."\n";

Browser other questions tagged

You are not signed in. Login or sign up in order to post.