Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > %x and mswin32: missing output (from binary character)

Reply
Thread Tools

%x and mswin32: missing output (from binary character)

 
 
Jerome Zago
Guest
Posts: n/a
 
      03-27-2006
$ cat write.rb
puts "ab\032cd"

$ cat execute.rb
print %x{ruby write.rb}

$ ruby execute.rb
ab
[I expected "ab→cd"]

$ ruby --version # I could reproduce with:
ruby 1.8.4 (2005-12-24) [i386-mswin32]
ruby 1.8.4 (2006-03-23) [i386-mswin32]
ruby 1.9.0 (2006-03-23) [i386-mswin32]

In comparison:

$ cat write.pl
print "ab\032cd\n"

$ cat execute.pl
print qx{perl write.pl};

$ perl execute.pl
ab→cd

$ perl --version
This is perl, v5.8.8 built for MSWin32-x86-multi-thread

-----

The following patch (against HEAD) solves this problem but might have unw=
anted
side-effects:

--- io.c.orig 2006-03-01 11:06:03.000000000 +0100
+++ io.c 2006-03-24 19:22:19.885940500 +0100
@@ -4380,15 +4380,15 @@
rb_f_backquote(VALUE obj, VALUE str)
{
volatile VALUE port;
VALUE result;
OpenFile *fptr;

SafeStringValue(str);
- port =3D pipe_open(1, &str, "r");
+ port =3D pipe_open(1, &str, "rb");
if (NIL_P(port)) return rb_str_new(0,0);

GetOpenFile(port, fptr);
result =3D read_all(fptr, remain_size(fptr), Qnil);
rb_io_close(port);

return result;



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
(8-bit binary to two digit bcd) or (8-bit binary to two digit seven segment) Fangs VHDL 3 10-26-2008 06:41 AM
Binary data, command output, and Ruby Phrogz Ruby 9 10-05-2007 07:58 AM
Binary output (literally 1's and 0's) noridotjabi@gmail.com C Programming 7 11-05-2006 12:28 AM
Re: missing feature classes and missing fields Gary Herron Python 2 07-04-2006 10:29 PM
RFC 1521 and missing binary Content-Transfer-Encoding in email module Andy Leszczynski Python 0 09-16-2005 02:19 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57