From: Mika Raento Date: April 24 2007 11:17am Subject: binary strings List-Archive: http://lists.mysql.com/ndb-connectors/38 Message-Id: <462DE73A.9020600@iki.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit %extend NdbRecAttr { %cstring_output_allocate_size(char ** s, int *slen, void()) void string_value(char ** s, int *slen) { char* ref=self->aRef(); *slen=ref[0]; ref++; *s=ref; } }; works nicely for strings that don't contain embedded NULLs. The problem is that there is a bug in SWIG_FromCharPtrAndSize for perl in 1.3.31 (and everything before that) that it doesn't actually use the size, but calls sv_setpv which uses strlen(). See http://permalink.gmane.org/gmane.comp.programming.swig.devel/16349 The way to fix is to either: 1) modify your local SWIG installation 2) see if SWIG svn works 3) copy the typemap with a different name for SWIG_FromCharPtrAndSize and copy the corrected function too None of which are really good. I'm going with 1) for now myself. I can't find any docs for %fragment. I'm wondering whether there would be a way to override the SWIG_FromCharPtrAndSize fragment. Mika