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

Discussion in 'Ruby' started by Jerome Zago, Mar 27, 2006.

  1. Jerome Zago

    Jerome Zago Guest

    $ 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;
    Jerome Zago, Mar 27, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. raavi
    Replies:
    2
    Views:
    911
    raavi
    Mar 2, 2006
  2. Armin Roehrl
    Replies:
    1
    Views:
    113
    Jamey Cribbs
    Feb 13, 2004
  3. Wolfgang Nádasi-Donner

    Ruby 1.9 mswin32 Installation and a Problem

    Wolfgang Nádasi-Donner, Jul 22, 2005, in forum: Ruby
    Replies:
    2
    Views:
    93
    Wolfgang Nádasi-Donner
    Jul 22, 2005
  4. Kis Gellért Imre
    Replies:
    1
    Views:
    385
    Kis Gellért Imre
    Apr 17, 2007
  5. Vassilis Rizopoulos

    Rubygems 0.9.5 and fastthread mswin32 gem

    Vassilis Rizopoulos, Dec 5, 2007, in forum: Ruby
    Replies:
    5
    Views:
    126
    Luis Lavena
    Dec 11, 2007
Loading...

Share This Page