Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

mb_convert_encoding returns empty string since PHP 8.1.0 #7898

Closed
RV7PR opened this issue Jan 6, 2022 · 2 comments
Closed

mb_convert_encoding returns empty string since PHP 8.1.0 #7898

RV7PR opened this issue Jan 6, 2022 · 2 comments

Comments

@RV7PR
Copy link

RV7PR commented Jan 6, 2022

Description

The following code:

<?php
$str = 'Test';

# Make sure string is in UTF-8 and strip invalid UTF-8 characters
$str = mb_convert_encoding($str, 'UTF-8', mb_list_encodings());

print_r($str);

Resulted in this output:


But I expected this output instead:

Test

This code is from a gist we use
https://gist.github.com/sgmurphy/3098978

PHP Version

PHP 8.1.0

Operating System

CentOS 7

@cmb69
Copy link
Member

cmb69 commented Jan 7, 2022

I can confirm this for PHP 8.1.1, but it looks like the issue has been fixed with f07c193, which is contained in PHP 8.1.2RC1. Could you please check with that pre-release?

@RV7PR
Copy link
Author

RV7PR commented Jan 7, 2022

[root@RO ~]# php81 -v
PHP 8.1.2RC1 (cli) (built: Jan  4 2022 18:35:06) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.1.2RC1, Copyright (c) Zend Technologies
[root@RO ~]# php81 -r 'print_r(mb_convert_encoding("Test", "UTF-8", mb_list_encodings()));'
Test

I can confirm that it's fixed🚀

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants