The substr function causes errors with Cyrillic characters

Started by sertlan, 22 July 2024, 17:38:32

Previous topic - Next topic
A financial contribution is greatly appreciated as a support, to help us to keep live the project.
If you like this project you can donate some piece of BitCoin to this address: bc1qy5tgq6tvrckac2a57unxvqcnxamrvhduve9sj9

sertlan

Hi federica.

The substr function causes errors with Cyrillic characters.
Example: Вашему вниманию предлагается полное собрание сочинен

It's better to use the mb_substr function.

Please replace in the file "components/com_abook/layouts/category/item.php"
this code:
<?php echo substr(strip_tags($item->description), 0100);?>with this code:
<?php echo mb_substr(strip_tags($item->description), 0100'UTF-8') . '...';?>

A financial contribution is greatly appreciated as a support, to help us to keep live the project.
If you like this project you can donate some piece of BitCoin to this address: bc1qy5tgq6tvrckac2a57unxvqcnxamrvhduve9sj9

federica

I found this Joomla core function. Try this code.
<?php echo HTMLHelper::_('string.truncate'strip_tags($item->description), 100,truefalse ); ?>
Let me know it is ok.
Al mondo ci sono 10 tipi di persone, quelli che hanno capito il codice binario e quelli che non l'hanno capito.
Informatizzati [url="https://informatizzati.org"]https://informatizzati.org[/url]
Stacca la spina [url="https://disconnessi.org"]https://disconnessi.org[/url]

sertlan

Quote from: federica on 22 July 2024, 18:50:39<?php echo HTMLHelper::_('string.truncate'strip_tags($item->description), 100,truefalse ); ?>
This code works without errors.

federica

I will publish a new beta version as soon as possible.
Al mondo ci sono 10 tipi di persone, quelli che hanno capito il codice binario e quelli che non l'hanno capito.
Informatizzati [url="https://informatizzati.org"]https://informatizzati.org[/url]
Stacca la spina [url="https://disconnessi.org"]https://disconnessi.org[/url]

A financial contribution is greatly appreciated as a support, to help us to keep live the project.
If you like this project you can donate some piece of BitCoin to this address: bc1qy5tgq6tvrckac2a57unxvqcnxamrvhduve9sj9