sprain / php-swiss-qr-bill

A PHP library to create Swiss QR bills | QR-Rechnung in PHP erstellen
MIT License
277 stars 81 forks source link

Problem in qrcode scan with special characters like German Umlaute ä,ö and ü #181

Closed mixgiogio closed 2 years ago

mixgiogio commented 2 years ago

Hi,

First of all, thanks for this precious library!

I report below the error that I encountered after generating the qr code.

Step1: i generete the qrcode and i use this methods:

QrBill\DataGroup\Element\StructuredAddress::createWithStreet(....));

in some of this field i have a special char like ä,ö and ü (for example Röli, Muff, Schöpfer).

Step 2: when i show the Swiss QR Bill payment in pdf i see correctly this special chars

Step 3: when i scan the qr code with banking mobile app or with dedicate scanner linked on pc the auto-populated fields show uncoded characters (for example: Röli ....

sprain commented 2 years ago

when i scan the qr code with banking mobile app or with dedicate scanner linked on pc the auto-populated fields show uncoded characters (for example: Röli ....

What do those names originally look like? Could it be that you encode them into html entities before adding them to the qr code?

mixgiogio commented 2 years ago

I retreive this value from a mysql database, this is the originary field stored in table "Röli, Muff, Schöpfer"... R& o u m l ;li, Muff, Sch & o u m l ; pfer... I added spaces because in the preview it is shown already encoded

FredBoard commented 2 years ago

Hi, Info I work as well datas with non-ascii in the Street adresse ... (" Châtelet , Südstrasse, Mâche ..." ) I have no problem to generate and decode the qr code.

merlincom commented 2 years ago

[https://www.php.net/manual/de/function.utf8-encode.php]

I suspect your data comes from a database. At least I have the same problem in this case, which I could solve with utf8_encode( 'Südstrasse' ).

Ich vermute, deine Daten kommen stammen aus einer Datenbank. Zumindest habe ich in diesem Fall das selbe Problem gehabt, das ich mit utf8_encode( 'Südstrasse' ) lösen konnte.

mixgiogio commented 2 years ago

Hi, resolved with html_entity_decode()

Thanks ;)

clementbirkle commented 2 years ago

I had this same problem. I solved it with \Normalizer::normalize() (PECL intl)

merlincom commented 2 years ago

\Normalizer::normalize() (PECL intl)

Can you please show a code snippet of your solution. Thank you.

Because: utf8_encode - Convert a string from ISO-8859-1 to UTF-8 Warning: This function is DEPRECATED as of PHP 8.2.0. It is strongly discouraged to use this function.

clementbirkle commented 2 years ago

Just like that:

$qrBill->setCreditor(
    QrBill\DataGroup\Element\CombinedAddress::create(
        \Normalizer::normalize('Röli Schöpfer'),
        \Normalizer::normalize('Rue du Lac 1268'),
        \Normalizer::normalize('2501 Biel'),
        'CH'
    ));