Re: [Rd] Embedded nuls in strings

2007-08-07 Thread Duncan Murdoch
On 07/08/2007 9:13 PM, Herve Pages wrote: > Duncan Murdoch wrote: >> On 07/08/2007 6:29 PM, Herve Pages wrote: > [...] >>> Same for serialization: >>> save(string0, file="string0.rda") load("string0.rda") string0 >>> [1] "ABCD" >> Of these, I'd say the serialization is the only case

Re: [Rd] Embedded nuls in strings

2007-08-07 Thread Herve Pages
Duncan Murdoch wrote: > On 07/08/2007 6:29 PM, Herve Pages wrote: [...] >> Same for serialization: >> >>> save(string0, file="string0.rda") >>> load("string0.rda") >>> string0 >> [1] "ABCD" > > Of these, I'd say the serialization is the only case where it would be > reasonable to fix the behaviour

Re: [Rd] Embedded nuls in strings

2007-08-07 Thread Duncan Murdoch
On 07/08/2007 6:29 PM, Herve Pages wrote: > Duncan Murdoch wrote: >> On 07/08/2007 5:06 PM, Herve Pages wrote: >>> Hi, >>> >>> ?rawToChar >>> 'rawToChar' converts raw bytes either to a single character string >>> or a character vector of single bytes. (Note that a single >>> charact

Re: [Rd] Embedded nuls in strings

2007-08-07 Thread Herve Pages
Duncan Murdoch wrote: > On 07/08/2007 5:06 PM, Herve Pages wrote: >> Hi, >> >> ?rawToChar >> 'rawToChar' converts raw bytes either to a single character string >> or a character vector of single bytes. (Note that a single >> character string could contain embedded nuls.) >> >> Allow

Re: [Rd] Embedded nuls in strings

2007-08-07 Thread Duncan Murdoch
On 07/08/2007 5:06 PM, Herve Pages wrote: > Hi, > > ?rawToChar > 'rawToChar' converts raw bytes either to a single character string > or a character vector of single bytes. (Note that a single > character string could contain embedded nuls.) > > Allowing embedded nuls in a string

Re: [Rd] Embedded nuls in strings

2007-08-07 Thread Steven McKinney
I get similar results on an Apple Mac G5 running OS X, though nchar() works. > raw0 <- as.raw(c(65:68, 0 , 70)) > string0 <- rawToChar(raw0) > raw0 [1] 41 42 43 44 00 46 > string0 [1] "ABCD\0F" > nchar(string0) [1] 6 > grep("F", string0) integer(0) > strsplit(string0, split=NULL, fixed=TRU