[Rd] readBin(what="character", n=overcount)->extra "" in result (PR#9361)

From: <bill_at_insightful.com>
Date: Mon 13 Nov 2006 - 17:09:52 GMT


Full_Name: Bill Dunlap
Version: 2.4.0
OS: Windows XP
Submission from: (NULL) (208.252.71.182)

When I use readBin() to read an unknown number of null-terminated strings from a file by supplying an overcount as the n= argument, it appends an empty string to the result.

> tf<-tempfile()
> strings<-c("One","Two","Three")
> writeBin(strings, con=tf)
> readBin(con=tf,what="character",n=100) # expect "One","Two","Three" only

[1] "One" "Two" "Three" ""
> readBin(con=tf,what="integer",size=1,signed=FALSE,n=100)
 [1] 79 110 101 0 84 119 111 0 84 104 114 101 101 0
> unlink(tf)

> version

               _                           
platform       i386-pc-mingw32             
arch           i386                        
os             mingw32                     
system         i386, mingw32               
status                                     
major          2                           
minor          4.0                         
year           2006                        
month          10                          
day            03                          
svn rev        39566                       
language       R                           
version.string R version 2.4.0 (2006-10-03)

R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue Nov 14 04:11:32 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 13 Nov 2006 - 20:30:38 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.