e$B1sF#$G$9!#e(B
StringIO#ungetc e$B$G@hF,$r1[$($Fe(B ungetc
e$B$7$h$&$H$7$?$H$-$N5sF0$,e(B
e$B%I%-%e%a%s%H$H$"$C$F$$$^$;$s!#e(B
e$B5sF0e(B:
$ ./ruby -v -rstringio -e ‘f = StringIO.new(“1234”); f.ungetc(?x); p
f.getc’
ruby 1.9.0 (2008-06-03 revision 16793) [i686-linux]
“x”
e$B%I%-%e%a%s%He(B:
Pushing back
behind the beginning of the buffer string is not possible. Nothing
will be done if such an attempt is made.
e$B$3$l$O<BAu$N%P%0$G$7$g$&$+!#e(B
e$B$^$?!“e(Bungetc e$B$,85$NJ8;zNs$rJQ99$9$k$N$O;EMM$G$7$g$&$+!#e(B
e$B$J$s$H$J$/!”!Ve(Breadonly e$B$J$i85$Ne(B string
e$B$OJQ99$5$l$J$$!W$H$$$&e(B
e$B;W$$$3$$r$7$F$$$?$N$G5$$K$J$j$^$7$?!#;W$$$3$$G$9$1$I!#e(B
e$B$D$$$G$K!"0J2<$N5sF0$O%P%0$C$]$/8+$($^$9!#e(B
$ ./ruby -v -rstringio -e ’
s = “\u3042\u3042\u3042”
f = StringIO.new(s, “r”)
f.getc
f.ungetc(?x)
p f.read
p s
’
ruby 1.9.0 (2008-06-03 revision 16793) [i686-linux]
"\x81\x82xe$B$“e(B”
"e$B$"e(Bxe$B$“e(B”