[0x00, 0x07, str1, str2, 0x00].pack(cA64A64c)
this is in fact, the exact way I need this packed. I understand how C
strings work and such, but this really isn't a C string, and it should
pack just fine.
I move from C to Ruby and all I have are problems... I was just fine
doing this with sprintf.
--
Posted via http://www.ruby-forum.com/.
Please show the *exact* code you are running, and the *exact* error you
are getting (use copy-paste for both), because what you have posted
doesn't make any sense and I cannot replicate the particular error you
claim to see.
>> [0x00, 0x07, str1, str2, 0x00].pack(cA64A64c)
NameError: undefined local variable or method `str1' for main:Object
from (irb):1
>> str1 = "abc"; str2 = "def"
=> "def"
>> [0x00, 0x07, str1, str2, 0x00].pack(cA64A64c)
NameError: undefined local variable or method `cA64A64c' for main:Object
from (irb):3
from :0
>> [0x00, 0x07, str1, str2, 0x00].pack("cA64A64c")
TypeError: can't convert Fixnum into String
from (irb):4:in `pack'
from (irb):4
from :0
>> [0x00, 0x07, str1, str2, 0x00].pack("ccA64A64c")
=> "\000\aabc
def \000"
>> [0x00, 0x07, str1, str2, 0x00].pack("ccA64A64c")
=> "\000\aabc\000
def \000"
>>
After removing the obvious bugs from your code it looks fine to me, so
if this doesn't do what you want, you'll have to explain what it is you
are trying to do.
In message "Re: Error: symbol string may not contain `\0'"
on Sat, 21 Nov 2009 00:10:21 +0900, Dylan Lukes <revenan...@gmail.com> writes:
|I resolved it.
Could you tell me how?
matz.