How to convert from mb_convert_encoding($file, 'UTF-8', 'Windows-1251') back?

1k Views Asked by At

In php I use

mb_convert_encoding($file, 'UTF-8', 'Windows-1251') 

and I need to convert this back as the output is not human readable. The current output looks like this

П„ПѓО№ОЅП„ПѓО№О»О±МЃ_3.jpg

When I tried

mb_convert_encoding($file, 'ASCII'),

it doesn't work.

EDITED:

I use this code to compare strings: There is a problem with diacritic like this: hundezubehör-für-sommer.jpg. Thats why I use the code below.

$image_files = scandir($dir);
foreach ($image_files as &$file) {
    $file = mb_convert_encoding($file, 'UTF-8', 'Windows-1251');
}
// ...
var_dump(in_array($file, $image_files)); 

It works fine but the code looks like this П„ПѓО№ОЅП„ПѓО№О»О±МЃ_3.jpg. I want to convert it back to human readable format.

0

There are 0 best solutions below