Issue #13131 has been updated by Benoit Daloze.

Status changed from Open to Rejected

You inverted the order of the arguments, it's the filename first:

    IO.binwrite('/tmp/test.txt', 0.chr)


----------------------------------------
Bug #13131: ArgumentError: string contains null byte
https://bugs.ruby-lang.org/issues/13131#change-62488

* Author: voob scout
* Status: Rejected
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 2.4.0
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
Why does this not work?:

IO.binwrite(0.chr, '/tmp/test.txt')

If it's not a bug, then please somebody explain - how strings containing null bytes can be written to disk?

say there's a thermal printer command [29, 49, 75, 2, 0, 49, 120].map(&:chr).join that needs to be part of data sent to print, how would this be accomplished in ruby?



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>