10-03-2023, 07:36 AM
Linux only.
Code: (Select All)
$CONSOLE:ONLY
DIM ch(1 TO 10) AS _UNSIGNED _BYTE
DIM a$, ff AS LONG, i AS INTEGER
'this should be an "unique" filename which contents get erased after use.
a$ = "/tmp/c10headevrancat"
'the "file" could go on forever, so get only the first 10 characters.
'could replace with "urandom" but there was none on the system I tried.
SHELL "cat /dev/random | head -c 10 > " + a$
ff = FREEFILE
OPEN a$ FOR BINARY AS ff
FOR i = 1 TO 10
GET #ff, , ch(i)
NEXT
CLOSE ff
'some terminals try to brute-force translate UTF-8 for high-bit characters
' so have to do something about them and about the "control" characters.
FOR i = 1 TO 10
IF ch(i) < 32 OR ch(i) > 126 THEN
PRINT " ("; str(ch(i)); ") "
ELSE
PRINT CHR$(ch(i));
END IF
NEXT
PRINT
SYSTEM