On Fri, 29 Jan 2016 16:45:40 -0800 (PST), Scotty C
<costo...@hotmail.com> wrote:

>i have a new issue. i wrote my data as char and end records with 'return. i 
>use (read-line x 'return) and the first record is 15 char. when i use
> (read-line-bytes x 'return) i get 23 byte. i have to assume that my old 
>assumption that an 8 bit char would write to disk as 8 bits is incorrect?

Yes and no.  Characters are not "bytes".  If you wrote the file
originally in text mode, then it is subject to locale settings in the
OS.  Racket can handle some different character representations, but
you have to select them deliberately.

If you want to work with byte strings you are going to do file I/O in
binary mode.


Also, note that if you display/print a byte string you are seeing
character representations of the bytes.  There will be extraneous '\'
escapes for values that don't represent printable characters.  The
small values you will be using all are unprintable ASCII control
characters.


>from documentation on read-char
>Reads a single character from in—which may involve reading several
>bytes to UTF-8-decode them into a character
>
>i get the feeling that i will need to read the entire file as i used to read it
>taking each record and doing the following:
>- convert the string record to a bignum record
>- convert the bignum record into a byte string
>- write the byte string to a new data file
>
>does that seem right?

Yes.   You probably do need to convert the files.  Your original
coding likely is not [easily] compatible with binary I/O.

George

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to