forked from moritz/ilbot
/
decode.t
53 lines (36 loc) · 895 Bytes
/
decode.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use strict;
use warnings;
use Encode qw(encode decode);
#use Smart::Comments;
use Test::Base tests => 10;
use IrcLog::WWW qw(my_encode);
run {
my $block = shift;
my $name = $block->name;
my $str = $block->str;
for my $enc (split /\s+/, $block->enc) {
my $utf8 = decode('utf8', $str);
my $bytes = encode($enc, $utf8);
### $bytes
my $got = my_encode($bytes);
is $got, $str, "$name - $enc";
}
};
__DATA__
=== TEST 1: Simplified Chinese
--- str: 你好,world!
--- enc: GB2312 big5 utf8
=== TEST 2: Traditional Chinese
--- str: 我想要你 hello 的身份證號碼
--- enc: big5 utf8
=== TEST 3: latin-1
--- str: gaal: mØØse!
--- enc: latin1 utf8
=== TEST 4: more latin
--- str
test: umlaute: ä ü ö
--- enc: latin1 utf8
=== TEST 5: unknown encodings...
--- str
<moritz> more unicode test: 수도쿠
--- enc: utf8