From: Randy Lawrence Date: 2004-07-17T16:13:35+09:00 Subject: Re: ext/dl problem with unsigned char* Randy Lawrence wrote: > Hi, > > 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*". > > Question 1: Is it wrong to pass a string object as a parameter which > might contain non-ascii values when the c function returns? > > Qustion 2: The before and after values of 'inOut' remains the same > unless the parameter type in line 4 is changed from "unsigned char*" to > "char*". What can I do to fix this without resorting to Base64 encoding? > > module FooLib > extend DL::Importable > dlload './foolib.so.0' > extern "int foo(unsigned char*, unsigned int)" #this line > end > > inOut = 'original data' > puts "before: #{inOut}" > result = FooLib.foo(inOut, inOut.length) > puts "after: #{inOut}" > Well...it seems just keeping it as "char*" in ruby seems to work fine even when the results are binary. Are there any known problems with this workaround? Wondering if there's some weird future binary value that will make this blow up.