From: "jeremyevans0 (Jeremy Evans)" Date: 2021-11-19T19:33:23+00:00 Subject: [ruby-core:106176] [Ruby master Bug#18350] String with foreign character results in: TypeError (nil can't be coerced into Integer) Issue #18350 has been updated by jeremyevans0 (Jeremy Evans). I cannot reproduce this on Windows using the default 437 code page (using Ruby 2.7.0) or on OpenBSD (using Ruby 2.7.4): ``` C:\Ruby27-x64\bin>chcp Active code page: 437 C:\Ruby27-x64\bin>set RUBYOPT=-Ku C:\Ruby27-x64\bin>irb irb(main):001:0> s = "P��rpura" irb(main):002:0> s => "P��rpura" irb(main):003:0> RUBY_VERSION => "2.7.0" ``` ``` $ RUBYOPT=-Ku irb27 irb(main):001:0> s = "P��rpura" => "P��rpura" irb(main):002:0> RUBY_VERSION => "2.7.4" ``` When I try it on Windows with the 65001 (UTF-8) code page, the entire command prompt window containing irb closes (not just the ruby process). I also tried with Ruby 3.0 and got the same result. I can paste the `s = "P��rpura"` text directly into the command prompt outside of irb, so it doesn't appear to be purely a Windows command prompt issue. You appear to be running on Mac, so the situation must be different there. Can you reproduce this issue with Ruby 3.0? ---------------------------------------- Bug #18350: String with foreign character results in: TypeError (nil can't be coerced into Integer) https://bugs.ruby-lang.org/issues/18350#change-94780 * Author: diadbrown (Dave Brown) * Status: Open * Priority: Normal * ruby -v: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin17] * Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN ---------------------------------------- ``` ruby 2.7.2 :001 > s = "P��rpura" Traceback (most recent call last): 7: from /Users/xxx/.rvm/rubies/ruby-2.7.2/bin/irb:23:in `
' 6: from /Users/xxx/.rvm/rubies/ruby-2.7.2/bin/irb:23:in `load' 5: from /Users/xxx/.rvm/rubies/ruby-2.7.2/lib/ruby/gems/2.7.0/gems/irb-1.2.6/exe/irb:11:in `' 4: from /Users/xxx/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/reline/unicode.rb:99:in `calculate_width' 3: from /Users/xxx/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/reline/unicode.rb:99:in `scan' 2: from /Users/xxx/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/reline/unicode.rb:108:in `block in calculate_width' 1: from /Users/xxx/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/reline/unicode.rb:108:in `+' TypeError (nil can't be coerced into Integer) 2.7.2 :002 > ``` Ruby 2.6.3 does not have this problem: ``` ruby 2.6.3 :001 > s = "P��rpura" => "P��rpura" 2.6.3 :002 > ``` -- https://bugs.ruby-lang.org/ Unsubscribe: