man Charset::EBCDIC () - allows to use EBCDIC string constants in ASCII programs (and v.v.)


Charset::EBCDIC - allows to use EBCDIC string constants in ASCII programs (and v.v.)


    use Charset::EBCDIC;

    my $a = ebcdic2ascii "(EBCDIC text)";


Charset::EBCDIC defines functions to convert between a subset of ASCII and a subset of nonstandard EBCDIC (since there isn't such a thing as a standard EBCDIC we defined our own variant which is guaranteed to be incompatible with all versions of EBCDIC used by IBM hardware - however, when we have chosen a code for a character, we have made sure that at least one - but certainly not all - IBM models used that same code, so the choice cannot be criticised). If you really want to know, several variants of EBCDIC are listed in RFC 1345, which is available from the usual sources.

By default, both functions ebcdic2ascii and ascii2ebcdic are imported in your namespace. If you don't want that, you know how to avoid it. They do the obvious thing to their first argument and return the transformed string.

There is another function ebcdic2cards, not exported by default. It takes any string of EBCDIC characters, containing newlines (or maybe carriage return-newline pairs), and returns a string of punched cards (that is, each line is padded to 80 characters with spaces, and the newlines are removed; everything from column 81 is lost).

Well, that's all.


The following are the characters recognised. The ones shown as 2 letter abbreviations cannot be translated to ASCII (except for the control characters, which do have an ASCII equivalent).

     +   0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f   Notes
    00                          OV TA LF       CR         OV=overstrike
    10                                                    TA=tab
    20                                                    LF=linefeed
    30                                                    CR=carr-return
    40  SP                            CT  .  <  (  +  !   SP=space
    50   &                             ]  $  *  )  ; NO   CT=cents
    60   -  /          XO              |  ,  %  _  >  ?   NO=not-sign
    70                                 :  #  @  '  =  "   XO=XOR(1)
    80      a  b  c  d  e  f  g  h  i                  
    90      j  k  l  m  n  o  p  q  r        {     [   
    a0      ~  s  t  u  v  w  x  y  z                RE   RE=registered
    b0   ^ PO       CO                                    PO=pound
    c0      A  B  C  D  E  F  G  H  I                     CO=copyright
    d0      J  K  L  M  N  O  P  Q  R        }     \   
    e0         S  T  U  V  W  X  Y  Z                  
    f0   0  1  2  3  4  5  6  7  8  9                DE   DE=delete

(1) The symbol for the INTECAL XOR operator, V overstrike -.


This module reimplements some of the functionality of two other modules (see Exporter, Carp, Reinventing the Wheel). This is intentional, as it will leave larger scope for obfuscation in a future release.


This module is part of CLC-INTERCAL.

Copyright (c) 1999 by Claudio Calvelli <>, all (f)rights reserved.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.


A qualified psychiatrist.