13 minutes ago, rje said:
I think..... just off the top of my head..... there are characters that are non-printable codes in one but printable in the other.... if the file is on the X16 then, surely there's a character that renders "wrong" (for some value of "wrong") if it's ASCII..... and therefore would never have a right to exist in a text file... hrmmmmmm.....
Establish guardrails, such as "this must be a text file", and then you'll be able to detect whether or not it's PETSCII by whether or not that first character is actually PETSCII printable. If it ain't, then assume that's a flag indicating the rest of the file is ASCII...?
For example, ASCII 15, 16, 21, 22, 23, 25, 26 appear to be printable, but not in PETSCII.
There might be some terminals or systems that render ASCII or 8859-15 control codes, but technically by the standard they have no visible representation. $00-$1F and $7F-$BF in ASCII are not printable in that context. Even though many of them aren't valid C source characters, for example, people will often include them anyway because compilers will not complain (it is either undefined or implementation defined behavior, I can't remember which off the top of my head.
That's not to be confused with the screen codes, which are distinct from the XSCII encoding.