line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Decode::Source;
|
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
25026
|
use 5.008;
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
53
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
5
|
1
|
|
|
1
|
|
10324
|
use Filter::Util::Call;
|
|
1
|
|
|
|
|
2831
|
|
|
1
|
|
|
|
|
75
|
|
6
|
1
|
|
|
1
|
|
2948
|
use Encode;
|
|
1
|
|
|
|
|
14718
|
|
|
1
|
|
|
|
|
738
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.01';
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $filter_is_on = 0;
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub import {
|
13
|
2
|
|
|
2
|
|
19
|
my $pkg = shift;
|
14
|
2
|
|
|
|
|
4
|
my $enc = "utf8";
|
15
|
2
|
50
|
|
|
|
10
|
$enc = shift if @_;
|
16
|
2
|
100
|
|
|
|
8
|
filter_del() if $filter_is_on++;
|
17
|
2
|
|
|
|
|
11
|
filter_add({_encoding => $enc});
|
18
|
2
|
|
|
|
|
48
|
return 1;
|
19
|
|
|
|
|
|
|
}
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub unimport {
|
22
|
1
|
|
|
1
|
|
29
|
filter_del();
|
23
|
1
|
|
|
|
|
1987
|
$filter_is_on = 0;
|
24
|
|
|
|
|
|
|
}
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub filter {
|
27
|
18
|
|
|
18
|
0
|
1343
|
my $obj = shift;
|
28
|
18
|
|
|
|
|
58
|
my $ok = filter_read();
|
29
|
18
|
50
|
|
|
|
80
|
$_ = decode $obj->{_encoding}, $_ if $ok > 0;
|
30
|
18
|
100
|
|
|
|
4674
|
$_ = "use utf8;$_" unless $obj->{_lines}++;
|
31
|
18
|
100
|
|
|
|
74
|
$obj->{_lines} = 0 if s/(no\s+Decode::Source)/no utf8;$1/go;
|
32
|
18
|
|
|
|
|
490
|
return $ok;
|
33
|
|
|
|
|
|
|
}
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1;
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 NAME
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Decode::Source - Run scripts written in encodings other than utf-8
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
use Decode::Source "iso-8859-1";
|
44
|
|
|
|
|
|
|
... code written in ISO-8859-1 ...
|
45
|
|
|
|
|
|
|
use Decode::Source "cp-850";
|
46
|
|
|
|
|
|
|
... code written in DOS codepage 850 ...
|
47
|
|
|
|
|
|
|
no Decode::Source;
|
48
|
|
|
|
|
|
|
... code written in US-ASCII ...
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 ABSTRACT
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Use alternative encodings/charsets for your program code.
|
53
|
|
|
|
|
|
|
Perl 5.8 or higher is required for use of this module.
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
B
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Decode::Source makes it possible to write perl programs in any script or
|
60
|
|
|
|
|
|
|
encoding supported by the C module. Variable names can contain
|
61
|
|
|
|
|
|
|
non-ASCII characters, just as when you use the C |
62
|
|
|
|
|
|
|
theese characters, both in identifiers and string literals, will be
|
63
|
|
|
|
|
|
|
decoded to perl's internal utf-8 form, before execution.
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
The syntax are similar to C |
66
|
|
|
|
|
|
|
also takes an optional argument with source encoding. This argument can be
|
67
|
|
|
|
|
|
|
any argument that C's C function accept as a valid
|
68
|
|
|
|
|
|
|
encoding. See also L.
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 EXAMPLE
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
use Decode::Source "windows-1252";
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
$åke = ["Åke Braun", "08-555 55 55"];
|
75
|
|
|
|
|
|
|
$örjan = ["Örjan Älg", "08-555 55 54"];
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
binmode STDOUT, ":encodings(cp850)";
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
printf "Name: %-20s Phone: %12s\n", @$_ for $åke, $örjan;
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 SEE ALSO
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
L, L, L
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 AUTHOR
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Magnus HEkansson, Emailto:magnus@mbox604.swipnet.seE
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Copyright 2003 by Magnus HEkansson
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify
|
94
|
|
|
|
|
|
|
it under the same terms as Perl itself.
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut
|