From: Takaaki Tateishi Date: 2004-07-19T00:16:25+09:00 Subject: Re: ext/dl problem with unsigned char* Randy Lawrence said: > The string I pass to a c function does not appear to get modified if I > use "unsigned char*" in ruby instead of plain "char*". Basically pointer types are treated as 'void*', but 'char*' is treated as string. So 'unsigned char *' is the pointer type and a string given as a parameter in ruby layer is automatically converted to a pointer object to a copy of the given string. I think your C function modified a copy of a string. > Question 1: Is it wrong to pass a string object as a parameter which > might contain non-ascii values when the c function returns? I recommend you to use String#to_ptr as follows, if you specify 'unsigned char *'. inOutPtr = inOut.to_ptr inOutLen = inOut.length result = FooLib.foo(inOutPtr, inOutLen) inOut = inOutPtr.to_s(inOutLen) ... -- Takaaki Tateishi