From: Phil Jackson Date: 2006-05-24T08:11:02+09:00 Subject: Re: Using rb_str_insert from c On Wed, May 24, 2006 at 07:37:21 +0900, Joel VanderWerf wrote: > Phil Jackson wrote: >> The function: >> >> static VALUE rb_str_insert(VALUE, VALUE, VALUE) >> >> is defined in string.c but is static and so is not avalible to me to call >> directly on my string. I have a feeling rb_funcall is my answer but I can't >> find any decent documentation on getting the functions ID. >> > Offhand I think this will work: > > id_insert = rb_intern("insert"); // you can do this once > > rb_funcall(str, id_insert, 2, idx, str2); You were spot-on, the mistake I was making was: ID id = rb_intern("insert"); rb_funcall(cur_str, id, 3, cur_str, idx, str2); Which I guess would be the Ruby equivilent of: str.insert(str, 1, "hello world") Thanks, Phil