This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
mark link type of exported functions for OS/2
[perl5.git] / ebcdic.c
1 #include "EXTERN.h"
2 #include "perl.h"
3
4 /* in ASCII order, not that it matters */
5 static const char controllablechars[] = "?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_";
6  
7 int
8 ebcdic_control(int ch)
9 {
10         if (ch > 'a') {
11                 char *ctlp;
12  
13                if (islower(ch))
14                       ch = toupper(ch);
15  
16                if ((ctlp = strchr(controllablechars, ch)) == 0) {
17                       die("unrecognised control character '%c'\n", ch);
18                }
19  
20                 if (ctlp == controllablechars)
21                        return('\177'); /* DEL */
22                 else
23                        return((unsigned char)(ctlp - controllablechars - 1));
24         } else { /* Want uncontrol */
25                 if (ch == '\177' || ch == -1)
26                         return('?');
27                 else if (0 < ch && ch < (sizeof(controllablechars) - 1))
28                         return(controllablechars[ch+1]);
29                 else
30                         die("invalid control request: '\\%03o'\n", ch & 0xFF);
31         }
32 }