Issue #8290 has been reported by knu (Akinori MUSHA).

----------------------------------------
Bug #8290: String#inspect should not represent NUL as "\0" when octal digits may follow.
https://bugs.ruby-lang.org/issues/8290

Author: knu (Akinori MUSHA)
Status: Open
Priority: Normal
Assignee: 
Category: core
Target version: next minor
ruby -v: ruby 2.1.0dev (2013-04-19 trunk 40366) [x86_64-freebsd9]
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN


Starting from Ruby 2.0.0, String#inspect represents the NUL character as "\0" but it is not appropriate at least when octal digits follow.
Not only is it confusing to human eyes but it also breaks the characteristic of String#inspect that you can "eval" the result to get the original string, though not guaranteed.

% ruby -ve 'p "\0"+"12"'

# ruby 1.8.7 (2012-10-12 patchlevel 371) [x86_64-freebsd9]
"\00012"
=> OK

# ruby 1.9.3p409 (2013-04-04) [x86_64-freebsd9]
"\u000012"
=> OK

# ruby 2.0.0p145 (2013-04-17 revision 40339) [x86_64-freebsd9]
"\012"
=> Confusing

# ruby 2.1.0dev (2013-04-19 trunk 40366) [x86_64-freebsd9]
"\012"
=> Confusing

Attached is a patch that fixes this issue.


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