5 use RT::Test tests => 16;
7 use constant HAS_ENCODE_GUESS => Encode::Guess->require;
8 use constant HAS_ENCODE_DETECT => Encode::Detect::Detector->require;
10 my $string = "\x{442}\x{435}\x{441}\x{442} \x{43f}\x{43e}\x{434}\x{434}\x{435}\x{440}\x{436}\x{43a}\x{430}";
13 local $Test::Builder::Level = $Test::Builder::Level + 1;
14 is( RT::I18N::_GuessCharset( Encode::encode($_[0], $_[1]) ), $_[2] || $_[0], "$_[0] guesses as @{[$_[2]||$_[0]]}" );
17 RT->Config->Set(EmailInputEncodings => qw(*));
19 skip "No Encode::Detect", 3 unless HAS_ENCODE_DETECT;
20 guess('utf-8', $string);
21 guess('cp1251', $string);
22 guess('koi8-r', $string);
25 RT->Config->Set(EmailInputEncodings => qw(UTF-8 cp1251 koi8-r));
27 skip "No Encode::Guess", 4 unless HAS_ENCODE_GUESS;
28 guess('utf-8', $string);
29 guess('cp1251', $string);
30 guess('windows-1251', $string, 'cp1251');
32 local $TODO = "Encode::Guess can't distinguish cp1251 from koi8-r";
33 guess('koi8-r', $string);
37 RT->Config->Set(EmailInputEncodings => qw(UTF-8 koi8-r cp1251));
39 skip "No Encode::Guess", 3 unless HAS_ENCODE_GUESS;
40 guess('utf-8', $string);
41 guess('koi8-r', $string);
43 local $TODO = "Encode::Guess can't distinguish cp1251 from koi8-r";
44 guess('cp1251', $string);
48 # windows-1251 is an alias for cp1251, post load check cleanups array for us
49 RT->Config->Set(EmailInputEncodings => qw(UTF-8 windows-1251 koi8-r));
50 RT->Config->PostLoadCheck;
52 skip "No Encode::Guess", 3 unless HAS_ENCODE_GUESS;
53 guess('utf-8', $string);
54 guess('cp1251', $string);
56 local $TODO = "Encode::Guess can't distinguish cp1251 from koi8-r";
57 guess('koi8-r', $string);
61 RT->Config->Set(EmailInputEncodings => qw(* UTF-8 cp1251 koi8-r));
63 skip "No Encode::Detect", 3 unless HAS_ENCODE_DETECT;
64 guess('utf-8', $string);
65 guess('cp1251', $string);
66 guess('koi8-r', $string);