phpearth / docker-php

🐳 Docker For PHP developers - Docker images with PHP, Nginx, OpenLiteSpeed, Apache, Lighttpd, and Alpine
https://docs.php.earth/docker
MIT License
261 stars 80 forks source link

iconv(): Wrong charset, conversion from `UTF-8' to `ASCII//TRANSLIT//IGNORE' is not allowed #3

Closed insekticid closed 5 years ago

insekticid commented 6 years ago

How to reproduce?

iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', 'šěýčíéáýřčíšýíščř');

How to fix?

RUN apk add --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing gnu-libiconv
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php

refs

nhlm commented 6 years ago

Fixing a thing by adding a testing channel to the repositories may lead into security issues. Not recommended.

petk commented 6 years ago

I've checked this issue and the fastest and most solid current solution is indeed the one mentioned above. Since the gnu-libiconv package doesn't depend on too many other packages that might break things or present security issues, it's coming to these Dockerfiles in the following commits... So thanks for reporting these issues.

Even better would be to fix PHP core on its way as well. From my tests, currently it is not possible to properly and conveniently build PHP on Alpine with iconv extension using anything other than musl's iconv implementation (which has very strict view on POSIX standards and lacks the iconv's translit).

In such cases another possible solution is to simply use Linux distribution with glibc such as Debian for base Docker image.

petk commented 6 years ago

This has now been fixed via a new gnu-libiconv package in the PHP.earth Alpine repository and patched PHP source code. I'll also send a PR to PHP source code, since the PHP iconv extension is not working as it should and doesn't get built when passing libiconv.

insekticid commented 6 years ago

tested and it works well

did you sent PR to PHP source code?

petk commented 6 years ago

I'm still preparing the PR for the php-src. For now, there is only a customized patch added to these builds.

peter279k commented 5 years ago

It looks like this issue has been resolved since php-7.x version.

This issue I think should be closed.

petk commented 5 years ago

Hello, I'm not sure if this has been directly fixed but I suggest moving this to PHP's side altogether - with the iconv different functionality when using the GNU's libiconv and maybe suggesting some sort of warning in the docs or something else that different iconv libraries or implementations mean also different functionalities... I'm not sure. But in any case closing this one as won't fix or at least a partial fix using custom build of GNU libiconv... Thanks.

arifulhb commented 3 years ago

I've added this code into one of my custom php:7.3.24-fpm-alpine3.12 docker images and that also did work great.

How to reproduce?

iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', 'šěýčíéáýřčíšýíščř');

How to fix?

RUN apk add --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing gnu-libiconv
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php

Thanks

gsusI commented 2 years ago

Fixed by installing php7-mbstring php7-iconv in that order

RUN apk --no-cache add php7-mbstring php7-iconv

Original solution here: https://github.com/docker-library/php/issues/240#issuecomment-355489551