On Fri, Jan 29, 2016 at 7:45 PM, Scotty C <costo...@hotmail.com> wrote:

> > my plan right now is to rework my current hash so that it runs byte
> strings instead of bignums.
>
> 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?
>
> 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?


I don't know for sure, because I don't know what your file format is like
(apologies again, if I missed it; I *did* realize after I sent my last
message that you are using a custom hash table). But, if you're just taking
the first N bytes of a record and using that as your key, then there's no
reason to go through a bignum. You can read bytes (as opposed to
characters) from an input port. Just use `read-bytes` or one of its
variants.

-Jon

-- 
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