From simon.urbanek at r-project.org  Sat Nov 21 23:27:58 2009
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Sat, 21 Nov 2009 17:27:58 -0500
Subject: [Rd] R strings, null-terminated or size delimited?
In-Reply-To: <4B0857DB.8060606@citycable.ch>
References: <4B0857DB.8060606@citycable.ch>
Message-ID: <22C4DF66-C380-4922-AAD0-3D274CBDC9E0@r-project.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



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