Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What needs to be installed for `iconv` to work with PHP8

I'm trying to migrate doctrine/rst-parser to Github actions, and the last hurdle is a test that fails because of a call to iconv:

iconv('utf-8', 'us-ascii//TRANSLIT', $text)

The test fails with

Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
     <li class="dash">Test list item 1.</li>
     <li class="dash">Test list item 2.</li>
 </ul>
-<p class="rot-gelb-blau grun-2008">Weird class names.</p>
+<p class="rot-gelb-blau grn-2008">Weird class names.</p>

I have tried installing the libc6 ubuntu package, and installing the iconv and intl PHP extensions, no dice. What should I try?

Here is a link to the pull request: https://github.com/doctrine/rst-parser/pull/126

EDIT: the solution seems to be to do a setlocale(LC_ALL, 'en_US');, but that returns false on github actions for some reason.

like image 522
greg0ire Avatar asked Oct 30 '25 02:10

greg0ire


1 Answers

Using setlocale(LC_ALL, 'en_US.utf8') fixes the issue. This is required since PHP 8: https://github.com/php/php-src/commit/c4ad8beaa890b931031a5cf8a1d2d38550fca3af

like image 74
greg0ire Avatar answered Oct 31 '25 17:10

greg0ire



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!