[Ironruby-core] byte[] to ruby string

Ivan Porto Carrero ivan at flanders.co.nz
Thu Oct 22 19:14:09 EDT 2009


you can just skip my email.. I tried my things now and none of them work.
---
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto Carrero
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)



On Fri, Oct 23, 2009 at 12:13 AM, Nathan Stults <Nathan_Stults at hsihealth.com
> wrote:

> I don't even get that far. When I do a File.read or a
> System::IO::File.read_all_bytes from IronRuby (iirb.exe), I get this (works
> OK in MRI):
>
> C:\>iirb
> irb(main):001:0> File.read("c:\\temp\\clickhere.png")
> File.read("c:\\temp\\clickhere.png")
> IOError: Not enough storage is available to process this command.
>
>        from mscorlib:0:in `WinIOError'
>        from mscorlib:0:in `Write'
>        from :0:in `write'
>        from c:/IronRuby/lib/ruby/1.8/irb.rb:302:in `output_value'
>        from :0:in `printf'
>        from :0:in `printf'
>        from c:/IronRuby/lib/ruby/1.8/irb.rb:151:in `eval_input'
>        from c:/IronRuby/lib/ruby/1.8/irb.rb:263:in `signal_status'
>        from c:/IronRuby/lib/ruby/1.8/irb.rb:147:in `eval_input'
>        from c:/IronRuby/lib/ruby/1.8/irb.rb:146:in `eval_input'
>        from :0:in `loop'
>        from c:/IronRuby/lib/ruby/1.8/irb.rb:70:in `start'
>        from c:/IronRuby/lib/ruby/1.8/irb.rb:69:in `start'
>        from :0:in `catch'
>        from c:/IronRuby/bin/iirb:13
>        from :0:in `catch'
> irb(main):002:0>
>
>
>
>
> -----Original Message-----
> From: ironruby-core-bounces at rubyforge.org [mailto:
> ironruby-core-bounces at rubyforge.org] On Behalf Of Håkon Clausen
> Sent: Thursday, October 22, 2009 2:13 PM
> To: ironruby-core at rubyforge.org
> Subject: [Ironruby-core] byte[] to ruby string
>
> Hello,
>
> I'm struggling with converting a byte array into a ruby binary string.
> Does anybody know how to make something like this pass?
>
> require 'test/unit'
> include System::IO
> class Binstring < Test::Unit::TestCase
>
>   def test_binstring_bytea
>     fileName = 'flowers.jpg'
>
>     #Ruby way
>     data1 = File.read(fileName)
>
>     #.Net
>     fs = FileStream.new(fileName, FileMode.Open, FileAccess.Read);
>     br = BinaryReader.new(fs);
>     numBytes = FileInfo.new(fileName).Length;
>     buff = br.ReadBytes(numBytes);
>     data2 = System::Text::ASCIIEncoding.new.GetString(buff).to_s
>
>     assert data1 == data2
>   end
>
> end
>
> Regards,
>
> Håkon
>
>
> --
> Håkon Clausen
> Nosyko AS
>
> "Nobody will ever need more than 640k RAM!" - Bill Gates, 1981.
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20091023/faf2b063/attachment.html>


More information about the Ironruby-core mailing list