Bug #3747: Possible bug of String#count?
http://redmine.ruby-lang.org/issues/show/3747
Author: Ruohao Li
Status: Open, Priority: Low
Category: M17N, Target version: 1.9.1
ruby -v: ruby 1.9.1p429 (2010-07-02 revision 28523) [i386-darwin9]
$ ruby -v
ruby 1.9.1p429 (2010-07-02 revision 28523) [i386-darwin9]
$ cat c.rb
# -*- coding: utf-8 -*-
s = "a\u3042" # \u3042 is the japanese hiragana "a"
puts s.encoding.name
puts s.count("^a")
$ ruby c.rb
UTF-8
0
The result of count method should be 1 but is 0.
on 2010-08-26 15:05
on 2010-08-26 15:42
Issue #3747 has been updated by Marcus Rückert.
didnt you want to say:
$ puts s.count("a")
1
if you do:
$ s = "^a\u3042"
$ puts s.count("^a")
1
----------------------------------------
http://redmine.ruby-lang.org/issues/show/3747
on 2010-08-26 15:48
In the documentation of String#count, "Any _other_str_ that starts with
a
caret (^) is negated". Thus s.count("^a") means the number of characters
that is *not* a, which should be 1.
on 2010-08-30 08:07
Issue #3747 has been updated by Yui NARUSE. Status changed from Assigned to Closed % Done changed from 0 to 100 This issue was solved with changeset r29146. Ruohao, thank you for reporting this issue. Your contribution to Ruby is greatly appreciated. May Ruby be with you. ---------------------------------------- http://redmine.ruby-lang.org/issues/show/3747
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.