Lingua::RU::Detect - Heuristics for guessing encoding sequence
use Lingua::RU::Detect "detect_enc"; say Dumper(detect_enc("бНОПНЯ")); say Dumper(detect_enc("бОДТЕК"));
Lingua::RU::Detect make a guess of how the original text was reconverted with a sequence of different encodings.
This module is a heart of http://decodr.ru/ website which provides a tool for automatic recovering Russian texts which were damaged by multiple transcodings. Two and three item chains are now available to detect, and the speed is much higher than that of programmes based on a dictionary.
The result of calling
detect_enc subroutine is a list of encoding pairs. To get original UTF-8 string you need to make all these transcodings in the order specified in the array returned. For example:
$VAR1 = [ [ 'UTF-8', 'ISO-8859-5' ], [ 'KOI8-R', 'UTF-8' ] ];
If no reencoding is needed, result is an empty array.
For test suite refer to Wikipedia page http://ru.wikipedia.org/wiki/%D0%9A%D1%80%D0%BE%D0%BA%D0%BE%D0%B7%D1%8F%D0%B1%D1%80%D1%8B (not all of them pass current version).
Andrew Shitov, <email@example.com>
Lingua::RU::Detect module is a free software. You may redistribute and (or) modify it under the same terms as Perl 5.10.