~ubuntu-branches/ubuntu/trusty/clc-intercal/trusty-proposed

« back to all changes in this revision

Viewing changes to INTERCAL/Charset/EBCDIC.pm

  • Committer: Bazaar Package Importer
  • Author(s): Mark Brown
  • Date: 2006-10-08 13:30:54 UTC
  • mfrom: (1.1.1 upstream) (3.1.1 dapper)
  • Revision ID: james.westby@ubuntu.com-20061008133054-fto70u71yoyltr3m
Tags: 1:1.0~2pre1.-94.-4.1-1
* New upstream release.
* Change to dh_installman.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package Language::INTERCAL::Charset::EBCDIC;
 
2
 
 
3
# Convert between EBCDIC and ASCII
 
4
 
 
5
# This file is part of CLC-INTERCAL.
 
6
 
 
7
# Copyright (C) 1999, 2000, 2002, 2006 Claudio Calvelli, all rights reserved
 
8
 
 
9
# CLC-INTERCAL is copyrighted software. However, permission to use, modify,
 
10
# and distribute it is granted provided that the conditions set out in the
 
11
# licence agreement are met. See files README and COPYING in the distribution.
 
12
 
 
13
use strict;
 
14
 
 
15
use vars qw($PERVERSION);
 
16
$PERVERSION = "CLC-INTERCAL INTERCAL/Charset/EBCDIC.pm 1.-94.-6";
 
17
 
 
18
use Carp;
 
19
 
 
20
use Language::INTERCAL::Exporter '1.-94.-4';
 
21
use vars qw(@EXPORT @EXPORT_OK);
 
22
@EXPORT = ();
 
23
@EXPORT_OK = qw(ascii2ebcdic ebcdic2ascii);
 
24
 
 
25
sub ebcdic2ascii {
 
26
    @_ == 1 or croak "Usage: ebcdic2ascii(STRING)";
 
27
    my $string = shift;
 
28
    $string =~ tr[\000-\037\100\112\113\114\115\116\117\120\132\133\134\135\136\137\140\141\145\152\153\154\155\156\157\172\173\174\175\176\177\201-\211\221-\231\234\236\241\242-\251\260\301-\311\321-\331\334\336\342-\351\360-\371\377]
 
29
                 [\000-\037\040\242\056\074\050\053\041\046\135\044\052\051\073\254\055\057\245\174\054\045\137\076\077\072\043\100\047\075\042\141-\151\152-\162\173\133\176\163-\172\136\101-\111\112-\122\175\134\123-\132\060-\071\177];
 
30
    $string;
 
31
}
 
32
 
 
33
sub ascii2ebcdic {
 
34
    @_ == 1 or croak "Usage: ascii2ebcdic(STRING)";
 
35
    my $string = shift;
 
36
    $string =~ tr[\000-\037\040\242\056\074\050\053\041\046\135\044\052\051\073\254\055\057\245\174\054\045\137\076\077\072\043\100\047\075\042\141-\151\152-\162\173\133\176\163-\172\136\101-\111\112-\122\175\134\123-\132\060-\071\177]
 
37
                 [\000-\037\100\112\113\114\115\116\117\120\132\133\134\135\136\137\140\141\145\152\153\154\155\156\157\172\173\174\175\176\177\201-\211\221-\231\234\236\241\242-\251\260\301-\311\321-\331\334\336\342-\351\360-\371\377];
 
38
    $string;
 
39
}
 
40
 
 
41
1;
 
42
 
 
43
__END__
 
44
 
 
45
=head1 NAME
 
46
 
 
47
Charset::EBCDIC - allows to use EBCDIC string constants in ASCII programs (and v.v.)
 
48
 
 
49
=head1 SYNOPSIS
 
50
 
 
51
    use Charset::EBCDIC 'ascii2abcdic';
 
52
 
 
53
    my $a = ebcdic2ascii "(EBCDIC text)";
 
54
 
 
55
=head1 DESCRIPTION
 
56
 
 
57
I<Charset::EBCDIC> defines functions to convert between a subset of ASCII and a
 
58
subset of nonstandard EBCDIC (since there isn't such a thing as a standard
 
59
EBCDIC we defined our own variant which is guaranteed to be incompatible
 
60
with all versions of EBCDIC used by IBM hardware - however, when we have
 
61
chosen a code for a character, we have made sure that at least one - but
 
62
certainly not all - IBM models used that same code, so the choice cannot
 
63
be criticised). If you really want to know, several variants of EBCDIC
 
64
are listed in RFC 1345, which is available from the usual sources.
 
65
 
 
66
Two functions, I<ebcdic2ascii> and I<ascii2ebcdic> are exportable but not
 
67
exported by default. They do the obvious thing to their first argument and
 
68
return the transformed string.
 
69
 
 
70
=head1 EBCDIC CHARACTER TABLE
 
71
 
 
72
The following are the characters recognised. The ones shown as 2 letter
 
73
abbreviations cannot be translated to ASCII (except for the control
 
74
characters, which do have an ASCII equivalent).
 
75
 
 
76
     +   0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f   Notes
 
77
    00                          OV TA LF       CR         OV=overstrike
 
78
    10                                                    TA=tab
 
79
    20                                                    LF=linefeed
 
80
    30                                                    CR=carr-return
 
81
    40  SP                            CT  .  <  (  +  !   SP=space
 
82
    50   &                             ]  $  *  )  ; NO   CT=cents
 
83
    60   -  /          XO              |  ,  %  _  >  ?   NO=not-sign
 
84
    70                                 :  #  @  '  =  "   XO=XOR(1)
 
85
    80      a  b  c  d  e  f  g  h  i                  
 
86
    90      j  k  l  m  n  o  p  q  r        {     [   
 
87
    a0      ~  s  t  u  v  w  x  y  z                RE   RE=registered
 
88
    b0   ^ PO       CO                                    PO=pound
 
89
    c0      A  B  C  D  E  F  G  H  I                     CO=copyright
 
90
    d0      J  K  L  M  N  O  P  Q  R        }     \   
 
91
    e0         S  T  U  V  W  X  Y  Z                  
 
92
    f0   0  1  2  3  4  5  6  7  8  9                DE   DE=delete
 
93
 
 
94
(1) The symbol for the INTECAL XOR operator, "V overstrike -".
 
95
 
 
96
=head1 COPYRIGHT
 
97
 
 
98
This module is part of CLC-INTERCAL.
 
99
 
 
100
Copyright (C) 1999, 2000, 2002, 2006 Claudio Calvelli, all rights reserved.
 
101
 
 
102
See the files README and COPYING in the distribution for information.
 
103
 
 
104
=head1 SEE ALSO
 
105
 
 
106
A qualified psychiatrist.
 
107