Guillaume Yziquel
2009-Nov-21 21:12 UTC
[Rd] R strings, null-terminated or size delimited?
Hello. I've been looking at vecsexps for my binding. Concerning strings, I'm wondering: are they supposed to be null-delimited? Are they delimited by the info in the SEXPHEADER macro in Rinternals.h? Basically, what are the macros or functions to access the values of the vecsexps? I'm thinking of CHARSXPs and INTSXPs for the moment... All the best, -- Guillaume Yziquel http://yziquel.homelinux.org/
On Nov 21, 2009, at 4:12 PM, Guillaume Yziquel wrote:> Hello. > > I've been looking at vecsexps for my binding. > > Concerning strings, I'm wondering: are they supposed to be null- > delimited?Yes, they are null-delimited when you create/access them.> Are they delimited by the info in the SEXPHEADER macro in > Rinternals.h? >You should not be touching or reading that.> Basically, what are the macros or functions to access the values of > the vecsexps?VECTOR_ELT and SET_VECTOR_ELT (assuming that you're referring to VECSXP which is are generic vectors).> I'm thinking of CHARSXPs and INTSXPs for the moment... >Those are entirely different - CHARSXP are not vectors but strings (see mkChar et al., CHAR, ...) and INTSXP are integer arrays (in C speak) accessed using INTEGER. Please read R-exts - it's better than guessing. Cheers, Simon