Skip to content

Undocumented mb_substr behaviour in PHP 8.3? #14703

Closed
@jahyvari

Description

@jahyvari

Description

The following code:

<?php
var_dump(
    mb_convert_encoding(
        mb_substr(
            mb_convert_encoding(
            	"test ääöö",
            	"ISO-8859-15",
            	"UTF-8"
            ),
            0,
            null,
            "UTF-8"
        ),
        "UTF-8",
        "ISO-8859-15"
    )
);

Resulted this output in PHP 8.2:

string(13) "test ääöö"

But resulted this output in PHP 8.3:

string(9) "test ????"

Based on this, did the pre PHP 8.3 mb_substr return the string always in the "raw" binary form, but in PHP 8.3 it will return the string using the passed encoding, and therefore could lead to an encoding conversion?

PHP Version

PHP 8.3.8

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions