search for: writechar

Displaying 20 results from an estimated 50 matches for "writechar".

2006 Aug 29
1
writeChar
I have recently been using writeChar and writeBin to write binary files. These functions makes it very easy to write OS-independent files, which I am very happy with. I have however found a few issues, best illustrated by a short example > con <- file("test", open = "wb") > writeChar(as.character(c...
2003 Nov 14
2
writeChar potential buffer overrun (PR#5090)
Trying to copy the (binary) header of a input file directly to an output file, I've had repeatable seg faults. The call: writeChar(hdr, outfh, nchars=6144) when hdr just contains one empty string seems to be the culprit. The stack traces weren't all that illuminating, with sig 11 in memory-related functions following this. But in src/main/connections.c it looks like do_writechar doesn't check the length of strings w...
2002 Jun 18
3
Maybe a problem in binary read/write (PR#1688)
...ions. If you have a PS/2 device you may try to run the following code: ascii <- sapply(1:255, function(i) parse(text=paste("\"\\",structure(i,class="octmode"),"\"",sep=""))[[1]]) dev <- file("/dev/psaux") open(dev, "w+b") writeChar(ascii[246], dev, eos=NULL) readBin(dev, what=integer(), n=1, size=1, signed=FALSE) writeChar(ascii[246], dev, eos=NULL) readBin(dev, what=integer(), n=1, size=1, signed=FALSE) close(dev) which gives: > ascii <- sapply(1:255, function(i) parse(text=paste("\"\\",structure(i,cla...
2001 Jul 17
1
How to write the bytes 00 01 00 to a file/connection?
Is there any way to write (8-bit) bytes to a file which works on all [R] platforms? I have been looking at 1) writeBin 2) writeChar 3) cat and neither of them manage to write arbitrary sequences of bytes (0-255). For instance, I would like to create a binary file of length three containing the bytes 0, 1 and 0. I [R] I have the following vector of bytes: bfr <- c(0,1,0) 1) For having 'writeBin' to write bytes...
2006 Mar 30
1
Writing character vectors with embedded nulls to a connection
Is this possible? I've tried both writeChar() and writeBin() to no avail. My goal is to serialize(ascii=FALSE) an object to a connection but determine the size of the serialized object before hand: sobject <- serialize(object,NULL,ascii=FALSE) len <- nchar(sobject) # # run some code here to notify listener on other end of connection...
2005 May 28
1
(PR#7899) seek(con, 0, "end", rw="r") does not always work
...wing this issue more closely, I think writeLines() into a binary connection might be the real problem and a misuse in this case. See the last paragrpah in the Details Section of ?writeLines. Hence, this might also be an issue related to the text mode connection problem on Windows. Using simple writeChar and readChar statements works as expected for me (at least, I was not able to produce anything unexpected). I'm no longer convinced that this is a bug in R. >> Note that ?seek currently tells us "The value returned by >> seek(where=NA) appears to be unreliable on Windows...
2003 Nov 06
2
Summary: How to represent pure linefeeds chr(10) under R for Windows
...pecification of line ending as "\r\n". Testing with these gave the following results: ## write.table / read.table: a bit inconsistent: need text connection to read and binary connection to write ## writeLines / readLines: readLines misses a sep= parameter to properly read in such data ## writeChar / readChar: OK Thanks again and Best regards Jens Oehlsch?gel ## Details filename <- "c:/tmp/c2.csv" ## write.table / read.table: a bit inconsistent: need binary connection to read and text connection to write data <- data.frame(a='c\nd', b='"???????"...
2006 Jun 02
1
Typo fix for readBin.Rd
...readBin.Rd +++ b/src/library/base/man/readBin.Rd @@ -58,7 +58,7 @@ writeBin(object, con, size = NA, endian \code{readBin} and \code{writeBin} read and write C-style zero-terminated character strings. Input strings are limited to 10000 - characters. \code{\link{readChar}} and \code{\code{writeChar}} + characters. \code{\link{readChar}} and \code{\link{writeChar}} Handling \R's missing and special (\code{Inf}, \code{-Inf} and
2008 Oct 28
2
writting null (\000 or ^@) to an external text file without the new warning
I have some functions that write an external text file for postprocessing by another program. Some instructions to the other program need to be indicated by null values (\000 or ^@). The function currently uses code like: writeChar(rawToChar(as.raw(0)), con) where con is a connection to the file. Previous to version 2.8.0 this worked fine. With 2.8.0 it still works, but I get a warning message about "truncating string with embedded null: '\0'" every time. This is documented and not a bug, but I still fin...
2024 Feb 17
1
certain pipe() use cases not working in r-devel
..., on linux using xsel or xclip). > > This is mentioned in the "Clipboard" section of the connections help > topic. > > > > In 4.3.2 on macOS, I can successfully roundtrip with the clipboard: > > > >> pb_write <- pipe("pbcopy") > >> writeChar("hello clipboard!", pb_write, eos = NULL) > >> pb_read <- pipe("pbpaste") > >> readChar(pb_read, 16) > > [1] "hello clipboard!" > > > > In r-devel, it appears that the write operation silently does nothing: > > > >>...
2018 Mar 29
2
Base R examples that write to current working directory
Hi all, Given the recent CRAN push to prevent examples writing to the working directory, is there any interest in fixing base R examples that write to the working directory? A few candidates are the graphics devices, file.create(), writeBin(), writeChar(), write(), and saveRDS(). I'm sure there are many more. One way to catch these naughty examples would be to search for unlink() in examples: e.g., https://github.com/wch/r-source/search?utf8=?&q=unlink+extension%3ARd&type=. Of course, simply cleaning up after yourself is not sufficien...
2024 Feb 14
2
certain pipe() use cases not working in r-devel
...oard on macOS using pbcopy/pbpaste (and, in very similar ways, on linux using xsel or xclip). This is mentioned in the "Clipboard" section of the connections help topic. In 4.3.2 on macOS, I can successfully roundtrip with the clipboard: > pb_write <- pipe("pbcopy") > writeChar("hello clipboard!", pb_write, eos = NULL) > pb_read <- pipe("pbpaste") > readChar(pb_read, 16) [1] "hello clipboard!" In r-devel, it appears that the write operation silently does nothing: > pb_write <- pipe("pbcopy") > writeChar("hel...
2016 Apr 15
0
R stops responding/communicating in for loop (lengthy description of issue)
...____________________________________________ test=c(1:50) frequency=c(5+(1*1:500)) response = c(1:500) number=c(1:500) dBm=0 newline=('\n') questionmark="?" out=fifo("usbsoft",open="w") volt=file("/dev/ttyUSB0",open="r+w") for(j in test){ writeChar("set freq 6.0000",out) Sys.sleep(1) for(i in number){ print(frequency[i]) #used to determine where the loop stops writeChar(questionmark,nchars=nchar(questionmark,type="chars"),volt,eos="\n") dBm=readChar(volt,n=5,useBytes=FALSE) response[i]=as.in...
2018 Mar 30
2
Base R examples that write to current working directory
...: >> Hi all, >> >> Given the recent CRAN push to prevent examples writing to the working >> directory, is there any interest in fixing base R examples that write >> to the working directory? A few candidates are the graphics devices, >> file.create(), writeBin(), writeChar(), write(), and saveRDS(). I'm >> sure there are many more. >> >> One way to catch these naughty examples would be to search for >> unlink() in examples: e.g., >> https://github.com/wch/r-source/search?utf8=?&q=unlink+extension%3ARd&type=. >> >&gt...
2007 Jun 14
1
Clarification for readChar man page
...y) @@ -57,8 +57,8 @@ } \value{ - For \code{readChar}, a character vector of length the number of - items read (which might be less than \code{length(nchars)}). + For \code{readChar}, a character vector of length 1 with the number + of characters less than or equal to nchars. For \code{writeChar}, a raw vector (if \code{con} is a raw vector) or invisibly \code{NULL}. Jeff -- http://biostat.mc.vanderbilt.edu/JeffreyHorner
2008 Feb 14
1
write output in a custom format
...a connection to a file and append to it a "particle" block in the format above, or even write the whole file at once. Because different lines have a different number of elements, I couldn't get write.table to work in this case, and my attempts at sink (), dump(), writeLines(), writeChar() all turn into really dirty solutions. I have this feeling I'm overlooking a simple solution. Any help welcome, baptiste _____________________________ Baptiste Augui? Physics Department University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton...
2002 Nov 29
2
readBin or writeBin adds extra nulls (PR#2333)
Full_Name: Ken Yap Version: 1.6.1 OS: Linux (SuSE 8.0) Submission from: (NULL) (129.78.64.5) I'm trying to copy a file using readBin and writeBin. (The reason is to be able to pipe PostScript or PDF output to a socket later, this is just an experiment.) I do: zz <- file("foo.ps", "rb") r <- readBin(zz, character(), 1000000) yy <- file("bar.ps",
2018 Apr 03
2
Base R examples that write to current working directory
...N push to prevent examples writing >>>> to the working directory, is there any interest in >>>> fixing base R examples that write to the working >>>> directory? A few candidates are the graphics devices, >>>> file.create(), writeBin(), writeChar(), write(), and >>>> saveRDS(). I'm sure there are many more. >>>> >>>> One way to catch these naughty examples would be to >>>> search for unlink() in examples: e.g., >>>> >>>> https://github.com/...
2001 Dec 07
2
Memory problem
...) header <- readChar(img,8192) imv <- readBin(img, "integer", n=1536*1536, size=2, signed=FALSE, endian="big") close(img) imm <- matrix(imv, nrow=1536, ncol=1536) imout <- file(paste("test_", fn[j], sep=""), "wb") writeChar(header, imout, nchars = 512, eos = NULL) #-------- for (i in 1:1536) { writeBin(pad, imout, size=2, endian="big") writeBin(imm[,i], imout, size=2, endian="big") writeBin(pad, imout, size=2, endian="big") } #-------- close(imout) rm( img, header,...
2018 Mar 30
0
Base R examples that write to current working directory
...gt;>> >>> Given the recent CRAN push to prevent examples writing to the working >>> directory, is there any interest in fixing base R examples that write >>> to the working directory? A few candidates are the graphics devices, >>> file.create(), writeBin(), writeChar(), write(), and saveRDS(). I'm >>> sure there are many more. >>> >>> One way to catch these naughty examples would be to search for >>> unlink() in examples: e.g., >>> >>> https://github.com/wch/r-source/search?utf8=?&q=unlink+extension%...