[MacRuby-devel] [MacRuby] #738: A character string cannot be taken out of the variable made by Pointer.new('c').
MacRuby
ruby-noreply at macosforge.org
Mon Jun 7 01:46:38 PDT 2010
#738: A character string cannot be taken out of the variable made by
Pointer.new('c').
----------------------------------+-----------------------------------------
Reporter: watson1978@… | Owner: lsansonetti@…
Type: defect | Status: closed
Priority: blocker | Milestone:
Component: MacRuby | Resolution: invalid
Keywords: |
----------------------------------+-----------------------------------------
Comment(by watson1978@…):
Thank you for your comment!
It modified the program as follows.
{{{
cat test_js.rb
framework "JavaScriptCore"
string = JSStringCreateWithUTF8CString("hello")
size = JSStringGetMaximumUTF8CStringSize(string)
buffer = Pointer.new('c', size)
ret = JSStringGetUTF8CString(string, buffer, size)
ary = []
(ret - 1).times do |i|
ary << buffer[i]
end
puts ary.pack('c*')
}}}
{{{
$ macruby test_js.rb
hello
}}}
I thought that I should be able to take the character from "buffer"
because I made it by Pointer.new('c').
--
Ticket URL: <http://www.macruby.org/trac/ticket/738#comment:2>
MacRuby <http://macruby.org/>
More information about the MacRuby-devel
mailing list