Bug fix : from iconv to use mb_convert_encoding

Di più
05/06/2021 18:27 #3688 da sam.marko2020@gmail.com
hi all,
LangUtils.php uses iconv in a function correctEncoding
now after hours of research I found that iconv does not correctly convert the encoding resulting on language labels not shown.

the fix is
replace
```
if (function_exists('iconv')) {
$text = iconv($current_encoding, $dest_encoding . '//IGNORE', $text);
} elseif ($current_encoding == 'ISO-8859-1' && $dest_encoding == 'UTF-8') {
$text = utf8_encode($text);
}
```
to
```
if (function_exists('mb_convert_encoding')) {
$text = mb_convert_encoding($text, $dest_encoding, $current_encoding);
} elseif ($current_encoding == 'ISO-8859-1' && $dest_encoding == 'UTF-8') {
$text = utf8_encode($text);
}
```

Si prega Accedi a partecipare alla conversazione.

Di più
10/06/2021 10:06 #3694 da dende
Hi Sam,
thanks for sharing.
Could you give an example of string not correctly encoded ?

Si prega Accedi a partecipare alla conversazione.

Di più
11/06/2021 05:03 #3697 da sam.marko2020@gmail.com
Hello @dende

Actually this function was failing for each and every string conversion during installation. I don't know if this may been related to the OS I used (Alpine Linux) or it is a bug existing anywhere else. The function was failing to convert a normal Ascii characters to UTF-8.
Researching on iconv it turned out to be an issue which exists for long time and well known in the PHP community, so the recommendation was to use mb_convert_encoding instead. This worked for me. I can try having a stock installation on Ubuntu and then see if this also fails, but I thought to share it with the community who may face similar issue.

Si prega Accedi a partecipare alla conversazione.

Di più
09/07/2021 16:57 #3735 da dende
Thank you !
Will share with Dev team

Si prega Accedi a partecipare alla conversazione.

Tempo creazione pagina: 0.141 secondi