summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-19 20:21:26 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-19 20:21:26 +0000
commit1e8a05c1dfee94db9b6b825097e1d192ad32930a (patch)
tree895f8c8502ba58553f9d1704f127081c82ef1631 /string.c
parent394d5dfa9ba625c99a1e6a411f81b628bfebd60a (diff)
Add example for String#scrub
[Feature #6321] [Feature #6752] [Bug #7967] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/string.c b/string.c
index 0cd155719b..83502a917d 100644
--- a/string.c
+++ b/string.c
@@ -7776,6 +7776,10 @@ str_compat_and_valid(VALUE str, rb_encoding *enc)
* 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)