method
dump
Related methods
- Class methods (3)
-
new
-
try_convert
(>= v1_9_1_378)
-
yaml_new
- Instance methods (148)
-
<<
-
<=>
-
=~
-
==
-
===
(>= v1_9_1_378)
-
[]
-
[]=
-
*
-
%
-
+
-
ascii_only?
(>= v1_9_1_378)
-
block_scanf
-
bytes
-
bytesize
-
byteslice
(>= v1_9_3_125)
-
capitalize
-
capitalize!
-
casecmp
-
center
-
chars
-
chomp
-
chomp!
-
chop
-
chop!
-
chr
(>= v1_9_1_378)
-
clear
(>= v1_9_1_378)
-
codepoints
(>= v1_9_1_378)
-
concat
-
count
-
crypt
-
delete
-
delete!
-
downcase
-
downcase!
-
dump
-
each
-
each_byte
-
each_char
-
each_codepoint
(>= v1_9_1_378)
-
each_line
-
empty?
-
encode
(>= v1_9_1_378)
-
encode!
(>= v1_9_1_378)
-
encoding
(>= v1_9_1_378)
-
end_regexp
-
end_with?
-
eql?
-
_expand_ch
-
expand_ch_hash
-
ext
(>= v1_9_3_125)
-
force_encoding
(>= v1_9_1_378)
-
getbyte
(>= v1_9_1_378)
-
gsub
-
gsub!
-
hash
-
hex
-
include?
-
index
-
initialize_copy
-
insert
-
inspect
-
intern
-
is_binary_data?
-
is_complex_yaml?
-
iseuc
-
isjis
(>= v1_9_1_378)
-
issjis
-
isutf8
-
jcount
-
jlength
-
jsize
-
kconv
-
length
-
lines
-
ljust
-
lstrip
-
lstrip!
-
match
-
mbchar?
-
next
-
next!
-
oct
-
ord
(>= v1_9_1_378)
-
original_succ
-
original_succ!
-
parse_csv
(>= v1_9_1_378)
-
partition
-
pathmap
(>= v1_9_3_125)
-
pathmap_explode
(>= v1_9_3_125)
-
pathmap_partial
(>= v1_9_3_125)
-
pathmap_replace
(>= v1_9_3_125)
-
prepend
(>= v1_9_3_125)
-
quote
(<= v1_8_6_287)
-
_regex_quote
-
replace
-
reverse
-
reverse!
-
rindex
-
rjust
-
rpartition
-
rstrip
-
rstrip!
-
scan
-
scanf
-
setbyte
(>= v1_9_1_378)
-
shellescape
-
shellsplit
-
size
-
slice
-
slice!
-
split
-
squeeze
-
squeeze!
-
start_with?
-
strip
-
strip!
-
sub
-
sub!
-
succ
-
succ!
-
sum
-
swapcase
-
swapcase!
-
to_c
(>= v1_9_1_378)
-
to_d
(>= v1_9_1_378)
-
toeuc
-
to_f
-
to_i
-
tojis
-
tolocale
(>= v1_9_1_378)
-
to_r
(>= v1_9_1_378)
-
to_s
-
tosjis
-
to_str
-
to_sym
-
toutf16
-
toutf32
(>= v1_9_1_378)
-
toutf8
-
to_yaml
-
tr
-
tr!
-
tr_s
-
tr_s!
-
unpack
-
upcase
-
upcase!
-
upto
-
valid_encoding?
(>= v1_9_1_378)
= private
= protected
dump()
public
Produces a version of str with all nonprinting characters replaced by nnn notation and all special characters escaped.
Show source
/* * call-seq: * str.dump => new_str * * Produces a version of <i>str</i> with all nonprinting characters replaced by * <code>\nnn</code> notation and all special characters escaped. */ VALUE rb_str_dump(str) VALUE str; { long len; char *p, *pend; char *q, *qend; VALUE result; len = 2; /* "" */ p = RSTRING(str)->ptr; pend = p + RSTRING(str)->len; while (p < pend) { char c = *p++; switch (c) { case '"': case '\\': case '\n': case '\r': case '\t': case '\f': case '\013': case '\010': case '\007': case '\033': len += 2; break; case '#': len += IS_EVSTR(p, pend) ? 2 : 1; break; default: if (ISPRINT(c)) { len++; } else { len += 4; /* \nnn */ } break; } } result = rb_str_new5(str, 0, len); p = RSTRING(str)->ptr; pend = p + RSTRING(str)->len; q = RSTRING(result)->ptr; qend = q + len; *q++ = '"'; while (p < pend) { char c = *p++; if (c == '"' || c == '\\') { *q++ = '\\'; *q++ = c; } else if (c == '#') { if (IS_EVSTR(p, pend)) *q++ = '\\'; *q++ = '#'; } else if (ISPRINT(c)) { *q++ = c; } else if (c == '\n') { *q++ = '\\'; *q++ = 'n'; } else if (c == '\r') { *q++ = '\\'; *q++ = 'r'; } else if (c == '\t') { *q++ = '\\'; *q++ = 't'; } else if (c == '\f') { *q++ = '\\'; *q++ = 'f'; } else if (c == '\013') { *q++ = '\\'; *q++ = 'v'; } else if (c == '\010') { *q++ = '\\'; *q++ = 'b'; } else if (c == '\007') { *q++ = '\\'; *q++ = 'a'; } else if (c == '\033') { *q++ = '\\'; *q++ = 'e'; } else { *q++ = '\\'; sprintf(q, "%03o", c&0xff); q += 3; } } *q++ = '"'; OBJ_INFECT(result, str); return result; }


