Skip to content

[BUG] php-iconv extension is still a problem on alpine #188

@mikespub

Description

@mikespub

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

With this base image and its derivatives, PHP packages like symfony/string that rely on the php-iconv extension internally still generate wrong output, e.g. when trying to convert Chinese to Ascii.

See https://gitlab.alpinelinux.org/alpine/aports/-/issues/15114 for details and context.

Expected Behavior

Convert strings correctly :-)

I assume that you'll prefer to wait for alpine's php-iconv package to work correctly someday, rather than try & fix this yourself, but at least we have a track of the issue here...
Adding the alpine package icu-data-full fixes the issue (but increases the image size).

Steps To Reproduce

$ composer require symfony/string
$ apk --no-cache add vim # use vim to edit utf-8 files
$ vim test.php

<?php

require_once __DIR__ . '/vendor/autoload.php';

// Sūnzǐ bīngfǎ = Sun Tzu's Art of War in Simplified Chinese
$input = "孙子兵法";
$output = (new \Symfony\Component\String\UnicodeString($input))->ascii();
$expected = "sun zi bing fa";
if ($expected == $output) {
    echo "Well done!\n";
} else {
    echo "Oops: $output != $expected\n";
}

$ php84 test.php
...
$ apk --no-cache add icu-data-full
$ php84 test.php
...

Environment

- OS: alpine 3.22
- How docker service was installed: N/A

Docker creation

N/A

Container logs

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions