php-iconv issue

2 posts / 0 new
Last post
#1 Tue, 2015-11-17 14:54
studna
  • studna's picture
  • Offline
  • Last seen: 1 year 8 months ago
  • Joined: 2015-11-17

Hi. I am trying to build some Docker image based on alpine linux. Everything works fine, but iconv do not.

$ apk update && apk add php-cli php-iconv
$ php -i | grep iconv
 
iconv
iconv support => enabled
iconv implementation => unknown
iconv library version => unknown
iconv.input_encoding => no value => no value
iconv.internal_encoding => no value => no value
iconv.output_encoding => no value => no value

<?php
// test.php
$text = "This is the Euro symbol '...'.";
echo 'Original : ', $text, PHP_EOL;
echo 'TRANSLIT : ', iconv("UTF-8", "ISO-8859-1//TRANSLIT", $text), PHP_EOL;
echo 'IGNORE   : ', iconv("UTF-8", "ISO-8859-1//IGNORE", $text), PHP_EOL;
echo 'Plain    : ', iconv("UTF-8", "ISO-8859-1", $text), PHP_EOL;

$ php test.php
Original : This is the Euro symbol '€'.
TRANSLIT : PHP Notice:  iconv(): Wrong charset, conversion from `UTF-8' to `ISO-8859-1//TRANSLIT' is not allowed in /tmp/test.php on line 8
IGNORE   : PHP Notice:  iconv(): Wrong charset, conversion from `UTF-8' to `ISO-8859-1//IGNORE' is not allowed in /tmp/test.php on line 9
Plain    : This is the Euro symbol '*'.

I also tried some others Docker images, but it seems it did not work either. Many thanks for any help.

Fri, 2016-02-26 18:53
warner
  • warner's picture
  • Offline
  • Last seen: 2 years 1 month ago
  • Joined: 2016-02-26

Hello. Have you tried this one - https://hub.docker.com/r/orukami/alpine-php/ ?
It build with libiconv instead of standart iconv.
The only problem i had with it it's an error then i tried to compile libiconv.
Quoted from here: https://github.com/mxe/mxe/issues/204

The problem is this part of srclib/stdio.in.h (a copy from gnulib) in the libiconv source:
 
/* It is very rare that the developer ever has full control of stdin,
   so any use of gets warrants an unconditional warning.  Assume it is
   always declared, since it is required by C89.  */
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
The assumption has become faulty, since C11 has dropped gets, and glibc has additionally dropped it for GNU sources after that. gnulib has been fixed, so the next libiconv release should be OK. 

This patch helped - https://github.com/mxe/mxe/blob/7e231efd245996b886b501dad780761205ecf376/src/libiconv-1-fixes.patch

Log in or register to post comments