Re: getc() ?? bug

new topic     » goto parent     » topic index » view thread      » older message » newer message

>  Derek:
>
>   Thats the problem but it seems that if a user wanted to read
>   a text file that contained a right arrow character ( a printable
>   character ) the interpeter should not return a EOF. I say that
>   is a bug.
>


So blame the DOS designers. The interpreter is not wrong in this case. How
can it know that for this specific text file, the ASCII-26 is not to be
interpreted as EOF, but on others it is? And just because DOS has a glyph
assigned to ASCII-26, does mean that it is a "printable" character according
to ASCII or ANSI.

Anyhow, the Euphoria behaviour is already documented. Here is an extract
from the open() documentation.
----------------------------------
open()
Syntax: fn = open(st1, st2)
Description: Open a file or device, to get the file number. -1 is returned
if the open fails. st1 is the path name of the file or device. st2 is the
mode in which the file is to be opened. Possible modes are:
"r" - open text file for reading
"rb" - open binary file for reading
"w" - create text file for writing
"wb" - create binary file for writing
"u" - open text file for update (reading and writing)
"ub" - open binary file for update
"a" - open text file for appending
"ab" - open binary file for appending


Files opened for read or update must already exist. Files opened for write
or append will be created if necessary. A file opened for write will be set
to 0 bytes. Output to a file opened for append will start at the end of
file.

Output to text files will have carriage-return characters automatically
added before linefeed characters. On input, these carriage-return characters
are removed. A control-Z character (ASCII 26) will signal an immediate end
of file.

I/O to binary files is not modified in any way. Any byte values from 0 to
255 can be read or written.

----------------------------------

If one needs to treat the bytes in a file in ways that are different from
the "text file" interpretation, one must open it as binary and do one's own
parsing. The built-in DOS commands work on the same principle.

-----
cheers,
Derek Parnell

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu