On 04/02/2011 5:35 AM, Christian Ruckert wrote:
To me it seems like writeBin() writes one char/byte more than expected.
You want writeChar rather than writeBin to avoid the null termination of
strings.
Duncan Murdoch
> con<- file("testbin", "wb")
> writeBin("ttccggaa", con)
> clos
from ?seek
‘seek’ returns the current position (before any move), as a
(numeric) byte offset from the origin, if relevant, or ‘0’ if not.
Your string is nul terminated (9 bytes long). That would be the
current offset. If you only read one byte, you'd have to be more than
0 bytes offset.
Je
To me it seems like writeBin() writes one char/byte more than expected.
> con <- file("testbin", "wb")
> writeBin("ttccggaa", con)
> close(con)
> con <- file("testbin", "rb")
> readBin(con, what="character")
[1] "ttccggaa"
> seek(con, what=NA)
[1] 9
> close(con)
> con <- file("testbin", "rb")
>