[Rd] R strings, null-terminated or size delimited?

Simon Urbanek simon.urbanek at r-project.org
Sat Nov 21 23:27:58 CET 2009


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



More information about the R-devel mailing list