[plt-scheme] I hate to bother the list with such a rudimentary question... but!

From: Matt Jadud (mcj4 at kent.ac.uk)
Date: Tue Jan 3 18:54:13 EST 2006

I think you're expecting behavior as you might get from "write-byte", 
but instead are getting something quite different from "write."

 > (write #x4d)
77
 > (char->integer #\7)
55
 > #x37
55

(write 77) is writing the Scheme expression "77" to the file in a format 
to be read by "read". It wrote two characters--both '7's--to the file.

I imagine the relevant references in the Help Desk might help clarify 
the behavior of "write", "read", and "write-byte".

Someone may end up chiming in with a more precise answer, but that's a 
quick response to get you started, I think.

M

geb a wrote:
> I'm trying to read/write hexadecimal code to files. 
> The problem I am having is that extra characters are
> always being added.  I have tried a number of methods
> and constantly end up with either extra characters or
> the wrong characters.
> 
> (define test #x4d )
> (define o (open-output-file  "test.out"
> 'truncate/replace 'binary))
> (write test o )
> (close-output-port o)
> 
> Can anyone tell me why this code might yield 
> 
> 37 37  or  77 when read by khexedit depending on
> whether you read hex or char.
> 
> Thank you for all you're help.
> 
> Sincerely
> 
> Dan
> 
> 
> 
> 
> 
> 		
> __________________________________________ 
> Yahoo! DSL – Something to write home about. 
> Just $16.99/mo. or less. 
> dsl.yahoo.com 
> 
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme


Posted on the users mailing list.