wc: Added wc
[mutos-utils.git] / vis.c
blob7260d62b44de25e2854962ccce91ac58172916e0
1 /*
2 Copyright © 2013 Alastair Stuart
4 This program is open source software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
15 #include <stdio.h>
17 int main()
19 int c = fgetc(stdin);
20 while (c != EOF)
22 int is_meta = 0;
24 if (c > 127 && c < 256) {
25 printf("M-");
26 is_meta = 1;
27 c -= 128;
30 if ((c >= ' ' && c <= '~') || ((c == '\t' || c == '\n') && !is_meta)) {
31 printf("%c", c);
32 } else if (c >= 0 && c < 32) {
33 printf("^%c", c+64);
36 if (c == 127) {
37 printf("^?");
40 c = fgetc(stdin);
43 return 0;