Skip to content

PHP > 8.1 fails to detect Māori macrons #11908

Closed
@RoSk0

Description

@RoSk0

Description

The following code:

<?php

$str = 'Total%20M%C4%81ori%2C31.5%2C33.3%2C31.8%2C33%2C36.4%2C33.2%2C33.2';
$rawstr = rawurldecode($str);

var_dump(
    mb_detect_encoding($rawstr, ['UTF-8', 'ISO-8859-1', 'WINDOWS-1251']),
    mb_detect_encoding($rawstr, ['ISO-8859-1', 'WINDOWS-1251', 'UTF-8']),
    mb_detect_encoding($rawstr, ['WINDOWS-1251', 'UTF-8', 'ISO-8859-1']),
    mb_check_encoding($rawstr, 'ISO-8859-1'),
    mb_check_encoding($rawstr, 'UTF-8'),
    mb_check_encoding($rawstr, 'WINDOWS-1251'),
);

https://3v4l.org/jYDqY

Resulted in this output:

string(12) "Windows-1251"
string(12) "Windows-1251"
string(12) "Windows-1251"
bool(true)
bool(true)
bool(true)

But I expected this output instead:

string(5) "UTF-8"
string(5) "UTF-8"
string(5) "UTF-8"
bool(false)
bool(true)
bool(false)

Related issues

PHP Version

PHP 8.1.22

Operating System

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions