Page 1 of 1

code like \n and \0 in ansi vs ascii

Posted: Sat Dec 12, 2020 9:56 am
by cborn
Hello,
One of the thinks thats new for me is the changing behavior of the c commands. an %c with 0 migth be interpreted as \0 but %d with 0 probably wont.
with the different libraries those comands change as well
like /b and /f which should be the same as chr$ 8 and 9 but not always.
an ascii table is easily found, http://www.asciitable.com/
ansi colours to, http://andrewnoske.com/wiki/Unix_-_ANSI_colors

is there a clear list with both cq all different codings?
there is a lot on internet but a complete list with both to compare seems missing
the next differs in behavior with or without lib=ansi
i put in those sleep since the effect might go to fast for a human
(edited 2x )

Code: Select all


/* zcc +zx -clib=ansi -vn slash-test.c -o slash-test -lndos -create-app */


#include <stdio.h>

int main(void)
{
int x , s=1 , i, j, n ;

sleep(s) ;
    printf("using \\ n Hello World!");
sleep(s);
    printf("Goodbye. \\ a \a");
sleep(s);
    printf("Hi \\ b .\b");
sleep(s);
    printf("Yo \\ f \f");
sleep(s);
    printf("What?. \\ t \t");
sleep(s);
    printf("pewpew \\ n \n");
sleep(s);

for (x=0 ; x<10 ; x++) { printf("%2d \n %2d",x , x+1);}
sleep(s);
printf("\n\n\n\n");
for (x=0 ; x<10 ; x++) {
          printf("%2d\v\b\b\b%2d",x , x+1);
          sleep(s);
              }

  for (i = 0; i < 11; i++) {
    for (j = 0; j < 10; j++) {
      n = 10*i + j;
      if (n > 108) break;
      printf("\e[%dm %3d\e[m", n, n);
    }
    printf("\n");
  }
          sleep(s);
printf("\xC");
sleep(s) ;
    printf("using \\ x hex  Hello World!");
sleep(s);
    printf("Goodbye. \\ x7 \x7");
sleep(s);
    printf("Hi. \\ x8 \x8");
sleep(s);
    printf("Yo \\ xC \xC");
sleep(s);
    printf("What?. \\ x9 \x9t");
sleep(s);
    printf("pewpew \\ xD \xD");
sleep(s);

for (x=0 ; x<10 ; x++) { printf("%2d \xD %2d",x , x+1);}
sleep(s);
printf("\xD\xD\xD\xD");
for (x=0 ; x<10 ; x++) {
          printf("%2d\xB\x8\x8\x8%2d",x , x+1);
          sleep(s);
              }

  for (i = 0; i < 11; i++) {
    for (j = 0; j < 10; j++) {
      n = 10*i + j;
      if (n > 108) break;
      printf("\x1b[%dm %3d\x1b[m", n, n);
    }
    printf("\n");
  }
          sleep(s);
printf("\xC");

sleep(s) ;
    printf("using \\ 000 oct  Hello World!");
sleep(s);
    printf("Goodbye. \\ 007 \007");
sleep(s);
    printf("Hi. \\ 010 \010");
sleep(s);
    printf("Yo \\ 014 \014");
sleep(s);
    printf("What?. \\ 011 \011");
sleep(s);
    printf("pewpew \\ 015 \015");
sleep(s);

for (x=0 ; x<10 ; x++) { printf("%2d \015 %2d",x , x+1);}
sleep(s);
printf("\015\015\015\015");
for (x=0 ; x<10 ; x++) {
          printf("%2d\011\010\010\010%2d",x , x+1);
          sleep(s);
              }
  for (i = 0; i < 11; i++) {
    for (j = 0; j < 10; j++) {
      n = 10*i + j;
      if (n > 108) break;
      printf("\033[%dm %3d\033[m", n, n);
    }
    printf("\n");
  }

sleep(s);

return 0;
}

Re: code like \n and \0 in ansi vs ascii

Posted: Sat Dec 12, 2020 12:19 pm
by cborn
edit:

BTW the 64 character counting seems not to be encouted for with some codes
and, the actual font used when i change to -ansi differes aswell, but thats extra

found my list here:
https://www.gaijin.at/en/infos/ascii-an ... cter-table

Re: code like \n and \0 in ansi vs ascii

Posted: Sun Dec 13, 2020 9:46 am
by dom
The default +zx screen driver supports the codes documented here: https://github.com/z88dk/z88dk/wiki/Cla ... ricConsole