Maxim Masiutin - 2020-04-04

Hello Dominik,

Please consider updating the "encodeString8bit" method to make the library compatible with (now deprecated) mbstring.func_overload.

For example, if the have the following options in php.ini (mbstring.func_overload = 2; mbstring.internal_encoding = "UTF-8"), the strlen returns the number of characters, not bytes. As a result, QR-encoding a string with national characters truncates the string.

To avoid this, just use count() after str_split(), since the last function is not affected by mbstring.func_overload.

The essence of the change is the following. In the function "encodeString8bit" replace

        $ret = $input->append(QR_MODE_8, strlen($string), str_split($string));

to

        $arr = str_split($string);
        $len = count($arr);

        $ret = $input->append(QR_MODE_8, $len, $arr);

so the users with mbstring.func_overload will be able to set $eightbit of the QREncode class to true to be able to encode QR codes with national characters

--
Maxim Masiutin
Ritlabs, SRL
Director