Skip to content

UConverter::transcode() always emits an E_WARNING when an invalid encoding is specified #17469

Closed

Description

@KidFlo

From manual page: https://php.net/uconverter.transcode


The documentation should mention that passing an invalid/unsupported encoding name to this method will result in an E_WARNING being emitted (and no error code defined), regardless of the values set for intl.use_exceptions or intl.error_level.

Activity

  1. Girgias commented on Jan 14, 2025

    @Girgias
    Member

    This seems more like a bug in the intl extension than a documentation issue. So transferring to php/php-src.

  2. transferred this issue fromphp/doc-enon Jan 14, 2025
  3. changed the title [-]UConverter::transcode() behavior when an invalid encoding is specified[/-] [+]UConverter::transcode() always emits an E_WARNING when an invalid encoding is specified[/+] on Jan 14, 2025
  4. devnexen commented on Jan 14, 2025

    @devnexen
    Member

    @Girgias with the following

    <?php
    UConverter::transcode("\x0a", 'nein!!', 'UTF-8');
    UConverter::transcode("\x0a", 'UTF-16BE', 'da!');
    ?>

    I get the E_WARNING

    Warning: UConverter::transcode(): Error setting encoding: 4 - U_FILE_ACCESS_ERROR in /home/dcarlier/test-intl.php on line 2
    
    Warning: UConverter::transcode(): Error setting encoding: 4 - U_FILE_ACCESS_ERROR in /home/dcarlier/test-intl.php on line 3

    is there a missing case ?

  5. Girgias commented on Jan 15, 2025

    @Girgias
    Member

    The issue is that it always emits a warning instead of being silenced/promoted to exception depending on the intl error setting as far as I understand.

  6. devnexen commented on Jan 15, 2025

    @devnexen
    Member

    Ah thanks. will have a look soon-ish.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions