Displaying 20 results from an estimated 1000 matches similar to: "Writing character vectors with embedded nulls to a connection"
2007 Jun 14
1
Clarification for readChar man page
Hi,
Here's a patch to the readChar manual page (R-trunk as of today) that
better clarifies readChar's return value. It could use some work as I'd
also like to add some text about using nchar() to find the length of the
string that readchar() returns, but I'm unsure which of type="bytes" or
type="chars" to mention. Is it type="chars"?
Index:
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
2003 Nov 06
2
Summary: How to represent pure linefeeds chr(10) under R for Windows
Thanks to all who have responded.
My concern was to be able to write a csv file that can have line feeds in
string columns chr(10).
Why? Excel allows line feeds chr(10) within cells and line breaks
chr(13)+chr(10) at line ending,
but the windows version of R automatically replaces \n by \r\n in writing
and \r\n by \n in reading (text mode).
The clues for a solution came from Brian Ripley and
2006 Jun 02
1
Typo fix for readBin.Rd
Hi,
The man page for readBin has a small typo:
--- a/src/library/base/man/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}}
+
2024 Feb 17
1
certain pipe() use cases not working in r-devel
I've now tested with:
> R.version.string
[1] "R Under development (unstable) (2024-02-16 r85931)"
and all of the previously mentioned examples now work as expected on macOS.
Thanks for the quick fix,
Jenny
On Thu, Feb 15, 2024 at 8:02?AM Tomas Kalibera <tomas.kalibera at gmail.com>
wrote:
>
> On 2/14/24 23:43, Jennifer Bryan wrote:
> > Hello,
> >
>
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",
2024 Feb 14
2
certain pipe() use cases not working in r-devel
Hello,
I've noticed a specific type of pipe() usage that works in released R, but
not in r-devel.
In 4.3.2 on macOS, I can write to a connection returned by pipe(), i.e.
"hello, world" prints here:
> R.version.string
[1] "R version 4.3.2 (2023-10-31)"
> con <- pipe("cat")
> writeLines("hello, world", con)
hello, world
But in r-devel on
2005 May 28
1
(PR#7899) seek(con, 0, "end", rw="r") does not always work
Tony Plate wrote:
> ligges@statistik.uni-dortmund.de wrote:
>
>> tplate@blackmesacapital.com wrote:
>>
>>
>>> I've noticed that seek(con, 0, "end", rw="r") on a file connection
>>> does not always work correctly after a write (R 2.1.0 on Windows).
>>>
>>> [Is a call to fflush() needed inside file_seek() in
2002 Apr 26
4
Memory "leak" in readChar (PR#1483)
Full_Name: Hugh C. Pumphrey
Version: 1.4.1
OS: Linux (Debian Woody)
Submission from: (NULL) (129.215.133.170)
The function readChar() appears to have some type of problem with memory
allocation.
I don't know if "memory leak" is the correct term but if one uses readChar()
many
times, the R binary grows in size until it eats all your memory and swap space.
The code enclosed below
2001 Dec 07
2
Memory problem
Dear all,
I have written a little R program to convert images. See below. Within the
loop over j (the filenames) memory consumption grows constantly. rm( ... )
inside the loop did not help. Memory does not grow if I remove the writeBin
statements between the two #-------- marks. But obviously this is not
solution I want...
Thanks for any advice.
Manfred Baumstark
P.S. As I'm new to R:
2018 May 29
1
Buffering in R 3.5 connections causes incorrect data in readChar
Tomas,
Thank you for the explanation. I see in the documentation: "These functions
are intended to be used with binary-mode connections." So I see how using
it on a text connection is undefined, and not a bug. An error or warning
when attempting to use a it on a text connection would be helpful
considering how the behavior has changed in R-3.5.
On Tue, May 29, 2018 at 3:09 AM, Tomas
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("ab", "ab")), nchars = c(3), con = con,
2002 Jun 18
3
Maybe a problem in binary read/write (PR#1688)
Full_Name: Johnny Accot
Version: 1.5.1
OS: Linux
Submission from: (NULL) (198.4.83.52)
Hi.
I'm having a problem with the binary read/write functions. I'm writing a device
driver in R (why not?) and of course I have to send a couple commands to the
device. Typically, I send one byte, receive one acknowledgement byte, send
another byte, receive an ACK, and so on. At least this is what
2000 Jun 29
1
Binary file functions in R
This is just to let people know that I'm going to try to put together
a little package of binary file read/write functions for R, along the
lines described in my message in r-help. I'm going to do it first in
R for Windows using a DLL written in Delphi; I'll let people comment
on that, and once the design settles down, I'll redo the external code
in C so that it should be portable
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
2010 May 05
1
handling nulls while reading mainframe file
Hi,
I am trying to read in records from an old main frame file. Each record is
640 bytes. I had some success using the following statement:
iconv(readChar(con, nchars=640, useBytes =
TRUE),from="IBM037",to="",sub="#")
What I have found, however, is that ocassionally a record will contain a
Null halfway through, which causes readChar() not to read the rest of the
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
2008 Feb 12
1
measuring sleep time in synchronization objects
Hi,
I am fairly new to DTrace, and wanted to ask something regarding
synchronization objects.
I have a multithreaded C++ program in which I use semaphores (POSIX version)
for synchronization. I was interested in using DTrace to figure out the
total time for which each thread in my application sleeps, blocked on a
semaphore, i.e., as a result of sem_wait() call. In order to measure this, I
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
2012 Dec 21
2
Difficulty importing data from PARI/GP
I'm trying to import a matrix created in PARI/GP into R but am having
problems.
The data in the text file has entries separated by commas but the rows
themselves are separated by semicolons rathen than being on a new line. Is
there a way to get R to recognise that ";" means start a new row ?
--
View this message in context: