getgrav / grav

Modern, Crazy Fast, Ridiculously Easy and Amazingly Powerful Flat-File CMS powered by PHP, Markdown, Twig, and Symfony
https://getgrav.org
MIT License
14.53k stars 1.41k forks source link

UTF-8 special character produce an error in templates #3716

Closed techws-dev closed 1 year ago

techws-dev commented 1 year ago

I upgraded to new version of Grav, and I have this error in some of my pages:

iconv(): Detected an illegal character in input string

I use utf-8 smileys in my pages, and a recent change in /system/src/Grav/Common/Helpers/Truncator.php is now throwing this error.

rhukster commented 1 year ago

Yes, i'm aware and currently looing for a solution. I tried the recommended replacement for mb_convert_encoding() with HTML_ENTITIES, as it's deprecated in PHP 8.2 and being removed in PHP 9. Unfortunately it doesn't work with extended characters such as smiley's and some other UTF-8 chars such as ⌘.

I will get a patched released out ASAP.

rhukster commented 1 year ago

please try replacing line 147 of the Truncator.php file with:

$html = mb_encode_numericentity($html, [0x80, 0x10FFFF, 0, ~0], 'UTF-8');
techws-dev commented 1 year ago

It works fine !! Thanks !!

rhukster commented 1 year ago

Great will release shortly.