Base64.decode64 does not work in 1.5.2 and 1.5.3 in Windows

In version 1.4.0 it works OK, but at least from 1.5.2 and above it does
not
work. This only happens in Windows, in Snow Leopard it is still working

The code for testing is this:

require “base64”
data =
“ACCSPROPEXT121010.TXT|UEsDBBQACAAIAOhITj0AAAAAAAAAAAAAAAAVAAAAQUNDU1BST1BFWFQxMjEwMTAuVFhUMzAM9lQI\nCPJ30zV2VFBAYik4KUCBqZGCggEQKKACZxcDZGAIYxiZm1oYGJobUAaMDC3NIfbARYBWAKEpmkJ3\nkJNDQ4AKDY2tDIDISAFNhW8Eirt5ebkMqOVpIwhlaWhhbGhgZGo0PD0dhuppYwgFjHALM0NLY3S3\nkQwMjSxp5mkAUEsHCPwyT7qBAAAA3wIAAFBLAQIUABQACAAIAOhITj38Mk+6gQAAAN8CAAAVAAAA\nAAAAAAAAAAAAAAAAAABBQ0NTUFJPUEVYVDEyMTAxMC5UWFRQSwUGAAAAAAEAAQBDAAAAxAAAAAAA\n”
data.gsub!(“\n”,“”)
data << “\n”
f = File.new(“test.zip”,“w”)
f.write(Base64.decode64(data))
f.close

The way I tested it is like this:
after compiling the file test_base64.rb

java -cp .;jruby-complete-1.4.0.jar test_base64

this creates a file: test.zip that can be unpacked

while this

java -cp .;jruby-complete-1.5.2.jar test_base64
generates a file that cannot be unpacked

By not workingI mean that the result is different from one version to
the
other, and I suppose it should be the same.

Is there something that needs to be configured in order to have it
working?


View this message in context:
http://old.nabble.com/Base64.decode64-does-not-work-in-1.5.2-and-1.5.3-in-Windows-tp29965414p29965414.html
Sent from the JRuby - User mailing list archive at Nabble.com.

Hi,

Sorry for late reply.

On Fri, Oct 15, 2010 at 03:39, jmurillo [email protected] wrote:

require “base64”
data =

“ACCSPROPEXT121010.TXT|UEsDBBQACAAIAOhITj0AAAAAAAAAAAAAAAAVAAAAQUNDU1BST1BFWFQxMjEwMTAuVFhUMzAM9lQI\nCPJ30zV2VFBAYik4KUCBqZGCggEQKKACZxcDZGAIYxiZm1oYGJobUAaMDC3NIfbARYBWAKEpmkJ3\nkJNDQ4AKDY2tDIDISAFNhW8Eirt5ebkMqOVpIwhlaWhhbGhgZGo0PD0dhuppYwgFjHALM0NLY3S3\nkQwMjSxp5mkAUEsHCPwyT7qBAAAA3wIAAFBLAQIUABQACAAIAOhITj38Mk+6gQAAAN8CAAAVAAAA\nAAAAAAAAAAAAAAAAAABBQ0NTUFJPUEVYVDEyMTAxMC5UWFRQSwUGAAAAAAEAAQBDAAAAxAAAAAAA\n”

data.gsub!(“\n”,“”)
data << “\n”
f = File.new(“test.zip”,“w”)

“w” must be “wb” in Windows.

f.write(Base64.decode64(data))
f.close

It’s a bug of JRuby 1.4 which does not handle “w” and “wb” correctly I
think.

Regards,
// NaHi

Thank you very much, it solved the problem, and it was not a late reply.

Hiroshi N.-3 wrote:

think.


View this message in context:
http://old.nabble.com/Base64.decode64-does-not-work-in-1.5.2-and-1.5.3-in-Windows-tp29965414p30003276.html
Sent from the JRuby - User mailing list archive at Nabble.com.