On 19/05/2018 12:33, Peter J. Holzer wrote:
On 2018-05-19 11:33:26 +0100, bartc wrote:
Not you understand why some of us don't bother with 'text mode' files.
"Not" or "Now"?
Now.
Yesterday you claimed that you worked with them for 40 years.
Text files, yes. Not 'text mode' which is something inflicted on us by
the C library.
(All my current programs can deal with lf or cr/lf line endings. I
dropped cr-only line endings as I hadn't seen such a file since the 90's.)
However if you have an actual EBCDIC system and would to read .ppm files,
then you will have trouble reading the numeric parameters as they are
expressed using sequences of ASCII digits.
I think the simplest way would be perform the calculation by hand
(new_value = old_value * 10 + next_byte - 0x30). At least in a language
which lets me process individual bytes easily. That would even work on
both ASCII and EBCDIC based systems (and on every other platform, too).
/The/ simplest? Don't forget the numbers can be several digits each.
Here's how I read them (NOT Python):
readln @f, width, height
Would it work in an EBCDIC based system? Probably not. But, who cares?
(I can't say I've never used such a system, but that was some ancient
mainframe from the 70s. But I'm pretty certain I won't ever again.)
(Perhaps someone who has access to an EBCDIC system can try a .PPM
reader to see what happens. I suspect that won't work either.)
--
bartc
--
https://mail.python.org/mailman/listinfo/python-list