[#66126] Creation/Conversion methods/functions table for Ruby types — SASADA Koichi <ko1@...>
Hi,
5 messages
2014/11/07
[#66248] [ruby-trunk - Feature #10423] [PATCH] opt_str_lit*: avoid literal string allocations — normalperson@...
Issue #10423 has been updated by Eric Wong.
3 messages
2014/11/13
[#66595] [ruby-trunk - Bug #10557] [Open] Block not given when the argument is a string — bartosz@...
Issue #10557 has been reported by Bartosz Kopinski.
3 messages
2014/11/30
[ruby-core:66082] [ruby-trunk - Bug #10476] String.strip remove characters different than pure whitespace
From:
nurachi@...
Date:
2014-11-04 16:34:53 UTC
List:
ruby-core #66082
Issue #10476 has been updated by Yves Le Douaron.
With the old 1.8.7 interpreter, the behaviour of strip was different:
~~~
1.8.7-head :010 > "#{0.chr}#{9.chr}#{10.chr}#{11.chr}#{12.chr}#{13.chr}#{32.chr}".strip
=> "\000"
1.8.7-head :011 > "#{0.chr}#{9.chr}#{10.chr}#{11.chr}#{12.chr}#{13.chr}#{32.chr}.#{0.chr}".strip
=> "\000\t\n\v\f\r ."
~~~
The null character was stripped from the end of the string but not from the beginning...
----------------------------------------
Bug #10476: String.strip remove characters different than pure whitespace
https://bugs.ruby-lang.org/issues/10476#change-49797
* Author: Yves Le Douaron
* Status: Open
* Priority: Normal
* Assignee: ruby-core
* Category: core
* Target version: current: 2.2.0
* ruby -v: ruby 2.1.3p242
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
The offical documentation (http://www.ruby-doc.org/core-2.1.4/String.html#method-i-strip) says:
**strip → new_str**
*Returns a copy of str with leading and trailing whitespace removed.*
But
~~~
[9] pry(main)> "#{0.chr}#{9.chr}#{10.chr}#{11.chr}#{12.chr}#{13.chr}#{32.chr}"
=> "\x00\t\n\v\f\r "
[10] pry(main)> "#{0.chr}#{9.chr}#{10.chr}#{11.chr}#{12.chr}#{13.chr}#{32.chr}".length
=> 7
[11] pry(main)> "#{0.chr}#{9.chr}#{10.chr}#{11.chr}#{12.chr}#{13.chr}#{32.chr}".strip
=> ""
~~~
~~~
([4] pry(main)> (0..255).each { |char| puts "char #{char} stripped" if char.chr.strip.empty? }
char 0 stripped
char 9 stripped
char 10 stripped
char 11 stripped
char 12 stripped
char 13 stripped
char 32 stripped
~~~
Stripped characters are
1. Null char (0)
1. Horizontal Tab (9)
1. Line Feed (10)
1. Vertical Tab (11)
1. Form Feed (12)
1. Carriage Return (13)
1. Space (32)
--
https://bugs.ruby-lang.org/