summaryrefslogtreecommitdiff
path: root/test/iso.t
blob: 19b27f318388c0855ca4205741f6f024e31aa6c6 (plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/perl

# Requires perl-Test-Simple installation.
use Test::Simple tests => 12;

$suffix = "";
if (-e "../dos2unix.exe") {
  $suffix = ".exe";
}
$DOS2UNIX = "../dos2unix" . $suffix;
$MAC2UNIX = "../mac2unix" . $suffix;
$UNIX2DOS = "../unix2dos" . $suffix;
$UNIX2MAC = "../unix2mac" . $suffix;

# To check for instance cp850 to iso88591 conversion
# you can do a visual check like this (on Windows).
#
# In a Windows Command Prompt, set font to Lucida Console.
# Then set the code page to 850:
#    chcp 850
# Display complete cp850 code page:
#    type chardos.txt
#
# In a Cygwin Mintty terminal, under Options->Text
# set Character set to ISO-8859-1
# Display converted character set:
#    cat iso_850.txt
#
# You now see the same characters as in the Windows Command Prompt
# with the non-convertable characters replaced with a dot.

system("$DOS2UNIX -v -437 -n chardos.txt out_unix.txt; cmp out_unix.txt iso_437.txt");
ok( $? == 0, 'DOS to Unix conversion, cp437 to iso88591' );

system("$DOS2UNIX -v -850 -n chardos.txt out_unix.txt; cmp out_unix.txt iso_850.txt");
ok( $? == 0, 'DOS to Unix conversion, cp850 to iso88591' );

system("$DOS2UNIX -v -860 -n chardos.txt out_unix.txt; cmp out_unix.txt iso_860.txt");
ok( $? == 0, 'DOS to Unix conversion, cp860 to iso88591' );

system("$DOS2UNIX -v -863 -n chardos.txt out_unix.txt; cmp out_unix.txt iso_863.txt");
ok( $? == 0, 'DOS to Unix conversion, cp863 to iso88591' );

system("$DOS2UNIX -v -865 -n chardos.txt out_unix.txt; cmp out_unix.txt iso_865.txt");
ok( $? == 0, 'DOS to Unix conversion, cp865 to iso88591' );

system("$DOS2UNIX -v -1252 -n chardos.txt out_unix.txt; cmp out_unix.txt iso_1252.txt");
ok( $? == 0, 'DOS to Unix conversion, cp1252 to iso88591' );


# To check for instance iso88591 to cp850 conversion
# you can do a visual check like this (on Windows).
#
# In a Cygwin Mintty terminal, under Options->Text
# set Character set to ISO-8859-1
# Display complete ISO-8859-1 character set:
#    cat charunix.txt
#
# In a Windows Command Prompt, set font to Lucida Console.
# Then set the code page to 850:
#    chcp 850
# Display converted cp850 code page:
#    type cp_850.txt
#
# You now see the same characters as in the Mintty terminal
# with the non-convertable characters replaced with a dot.

system("$UNIX2DOS -v -437 -n charunix.txt out_dos.txt; cmp out_dos.txt cp_437.txt");
ok( $? == 0, 'Unix to DOS conversion, iso88591 to cp437' );

system("$UNIX2DOS -v -850 -n charunix.txt out_dos.txt; cmp out_dos.txt cp_850.txt");
ok( $? == 0, 'Unix to DOS conversion, iso88591 to cp850' );

system("$UNIX2DOS -v -860 -n charunix.txt out_dos.txt; cmp out_dos.txt cp_860.txt");
ok( $? == 0, 'Unix to DOS conversion, iso88591 to cp860' );

system("$UNIX2DOS -v -863 -n charunix.txt out_dos.txt; cmp out_dos.txt cp_863.txt");
ok( $? == 0, 'Unix to DOS conversion, iso88591 to cp863' );

system("$UNIX2DOS -v -865 -n charunix.txt out_dos.txt; cmp out_dos.txt cp_865.txt");
ok( $? == 0, 'Unix to DOS conversion, iso88591 to cp865' );

system("$UNIX2DOS -v -1252 -n charunix.txt out_dos.txt; cmp out_dos.txt cp_1252.txt");
ok( $? == 0, 'Unix to DOS conversion, iso88591 to cp1252' );