[前][次][番号順一覧][スレッド一覧]

ruby-changes:28339

From: naruse <ko1@a...>
Date: Sat, 20 Apr 2013 05:21:35 +0900 (JST)
Subject: [ruby-changes:28339] naruse:r40391 (trunk): Add example for String#scrub

naruse	2013-04-20 05:21:26 +0900 (Sat, 20 Apr 2013)

  New Revision: 40391

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40391

  Log:
    Add example for String#scrub
    
    [Feature #6321] [Feature #6752] [Bug #7967]

  Modified files:
    trunk/string.c

Index: string.c
===================================================================
--- string.c	(revision 40390)
+++ string.c	(revision 40391)
@@ -7776,6 +7776,10 @@ str_compat_and_valid(VALUE str, rb_encod https://github.com/ruby/ruby/blob/trunk/string.c#L7776
  *  If the string is invalid byte sequence then replace invalid bytes with given replacement
  *  character, else returns self.
  *  If block is given, replace invalid bytes with returned value of the block.
+ *
+ *     "abc\u3042\x81".scrub #=> "abc\u3042\uFFFD"
+ *     "abc\u3042\x81".scrub("*") #=> "abc\u3042*"
+ *     "abc\u3042\xE3\x80".scrub{|bytes| '<'+bytes.unpack('H*')[0]+'>' } #=> "abc\u3042<e380>"
  */
 VALUE
 rb_str_scrub(int argc, VALUE *argv, VALUE str)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]