: Re: [Ironruby-core] byte[] to ruby string
<"This is a test\n"> expected but was
<"This is a test\r\n">.
windows default is to use CRLF for a new line and the CLR inherits that
But for ruby the new line constant is a LF which ruby inherits from *nix based
systems
<"This is a test\n"> expected but was
<"This is a test\r\n">.
windows default is to use CRLF for a new line and the CLR inherits that
But for ruby the new line constant is a LF which ruby inherits from *nix
based systems
the dirty workaround is
either specify data0 = "This is a test\r\n"
or
data1
Thanks,
CreateBinary made the picture file pass the test.
I'm having some trouble with some plain text and newlines. Any idea why
"test_3" don't pass?
require 'test/unit'
include System::IO
class Binstring < Test::Unit::TestCase
def test_1
fileName = 'flowers.jpg'
#Ruby
data1 =
In this particular case, I would recommend to use .NET API:
>>> include System::IO
=> Object
>>> stream = FileStream.new("c:\\temp\\a.txt", FileMode.Open, FileAccess.Read)
=> System.IO.FileStream
>>> "".Append(stream, stream.Length)
=> "hello"
Tomas
-Original Message-
From: ironruby-core
> String.CreateBinary().Append(a, 3, 3)
=> "\000A\000"
Tomas
From: ironruby-core-boun...@rubyforge.org
[mailto:ironruby-core-boun...@rubyforge.org] On Behalf Of Ivan Porto Carrero
Sent: Thursday, October 22, 2009 4:14 PM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] byte[]
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
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 th
File.open(filename, 'rb:BINARY) { |f| f.read } might help not sure though.
You can also look into the unpack method of a string that is used for
returning a bunch of different serialization formats.
http://www.ruby-doc.org/core/classes/String.html#M000760
---
Met vriendelijke groeten - Best regar