Click here to Skip to main content
15,887,341 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I use this site to convert sequence of bytes like this:

Рабыни

into proper character sequences like this:

Рабыни

It seems that the site decodes the UTF8 sequences into their original characters. For some reason, some of my files names are corrupted and I need to convert them back to their original.

Since number of files is not less, I decided to write a perl script for this purpose. I tried this

PERL
#!/usr/bin/perl
use utf8;
$str = "Рабыни.avi";
utf8::decode($str);
binmode STDOUT, ":utf8";
print "$str\n";


as a test on one file name. When running the script, I redirect the output to a file. When I see the content of the file, I see that the content is the same as the input string and no conversion is made. This is while the output is consistent to what the site converts for sequences like this:

ангелов

I tried running the script on both Linux (Ubuntu) and Windows by using ActivePerl and both give the same result. Concentrating on Windows, what do you think to be the error of the script?

Thanks

What I have tried:

I tried to manually rename the files, but since they're lots of file, it takes time and need effort.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900