From cb76c0350fe7db41bae61c2eccc328bca19f394c Mon Sep 17 00:00:00 2001 From: tTh Date: Mon, 3 Oct 2022 17:45:11 +0200 Subject: [PATCH] rester bien sagement en ASCII --- misctools/README.md | 5 +++++ misctools/nonascii.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 misctools/README.md create mode 100644 misctools/nonascii.c diff --git a/misctools/README.md b/misctools/README.md new file mode 100644 index 0000000..3f3b4d1 --- /dev/null +++ b/misctools/README.md @@ -0,0 +1,5 @@ +# Outils divers + + +## non ascii ? + diff --git a/misctools/nonascii.c b/misctools/nonascii.c new file mode 100644 index 0000000..a5682cd --- /dev/null +++ b/misctools/nonascii.c @@ -0,0 +1,33 @@ +/* + * nonascii.c + * + * new Mon 03 Oct 2022 05:42:42 PM CEST + */ + +#include +#include + +int main(int argc, char *argv[]) +{ +int input, linenum, count; + +linenum = 1; +count = 0; + +while (EOF != (input=getc(stdin))) { + + if ('\n' == input) linenum++; + + if ((input < 0) || (input>127)) { + fprintf(stderr, "non ascii 0x%x line %d\n", + input, linenum); + count++; + } + } +if (count) { + fprintf(stderr, "%d non-ascii chars\n", count); + exit(1); + } + +return 0; +} \ No newline at end of file