root/Encode-First/trunk/t/01_encode.t

Revision 2184 (checked in by miyagawa, 14 years ago)

import Encode::First

Line 
1 use strict;
2 use Test::Base;
3 use Encode::First;
4 use Encode;
5
6 plan tests => 2 * blocks;
7 filters 'chomp';
8
9 run {
10     my $block = shift;
11     my $str   = decode_utf8($block->input);
12
13     my $buffer = $block->input;
14     Encode::from_to($buffer, "utf-8", $block->encoding);
15
16     my($enc, $bytes) = encode_first($block->encodings, $str);
17     is $enc, $block->encoding, "encoding is $enc";
18     is $bytes, $buffer, $block->name;
19 };
20
21 __END__
22
23 === simple us-ascii
24 --- input
25 Hello World
26 --- encodings
27 us-ascii
28 --- encoding
29 us-ascii
30
31 === us-ascii as a list
32 --- input
33 Hello World
34 --- encodings
35 us-ascii,latin-1
36 --- encoding
37 us-ascii
38
39 === latin-1 beats us-ascii
40 --- input
41 Hello World
42 --- encodings
43 latin-1,us-ascii
44 --- encoding
45 latin-1
46
47 === latin-1 characters
48 --- input
49 Héllo World
50 --- encodings
51 ascii,latin-1
52 --- encoding
53 latin-1
54
55 === Japanese with iso-2022-jp
56 --- input
57 こんにちは
58 --- encodings
59 us-ascii,latin-1,iso-2022-jp
60 --- encoding
61 iso-2022-jp
62
63 === Japanese with utf-8
64 --- input
65 こんにちは
66 --- encodings
67 us-ascii,latin-1,utf-8
68 --- encoding
69 utf-8
70
71 ===
72 --- input
73 專業的研發團
74 --- encodings
75 ascii,latin-1,big5
76 --- encoding
77 big5
78
79 ===
80 --- input
81 파숙지
82 --- encodings
83 ascii,latin-1,iso-2022-kr
84 --- encoding
85 iso-2022-kr
86
87 === Unicode
88 --- SKIP
89 --- input
90 파숙지 專業的研發團 こんにちは
91 --- encodings
92 ascii,latin-1,euc-jp,iso-2022-jp,iso-2022-kr,big5,utf-8
93 --- encoding
94 utf-8
Note: See TracBrowser for help on using the browser.