Php Warning: iconv(): Cannot open converter

I have installed the opkg install php8-mod-iconv module and I am getting the above error when using the iconv() function. Please can someone advise what to do with it? Google didn't help me.

And what sysinfo says about iconv decoders available?

I don't know how to use sysinfo to get information

php --info | grep -A 20 ^iconv$

php: not found

after some tests i came to the opinion that it doesn't know the windows-1250 encoding

iconv -l
....
KOI8-RU
CP1250 MS-EE WINDOWS-1250
CP1251 MS-CYRL WINDOWS-1251
....

in the dump i found the line: CP1250 MS-EE WINDOWS-1250 but iconv('UTF-8', 'Windows-1250', any string) doesn't work

2 other strings in line should also work.

neither CP1250 nor MS-EE doesn't work

As per

upgrade to openwrt 23.05 and issue be gone ( or glibc like x86)

1 Like

thank you for your willingness

You can report new issue if iconv fails on v23 again...

I reworked the code and use sheel to run iconv, which will eventually convert the file to Windows-1250 encoding

If php iconv is non-functional also in v23.05 then report a bug. Kind of exec-ing commands defeats advantage of PHP over cgi shell script.

so I tried to install the current version of OpenWrt 23.05.3 and when I try to convert in php command iconv from UTF-8 to Windows-1250 I get this error: Warning: iconv(): Wrong encoding, conversion from "UTF-8" to "Windows-1250" is not allowed

Can you convert it from UTF8 to UTF8?

from utf8 to utf8 conversion will happen without error

It may depend on LC_ALL setting, but must be unset in both command and php environments.

in the php script I had setlocale(LC_ALL, 'cs_CZ') and when I removed it, the error remained the same