Str.encode("utf-32le", :invalid=>:replace)

UTF-8 [email protected]$7$/$J$$$b$N$re(B String#encode e$B$Ge(B UTF-32LE
e$B$KJQe(B
e$B49$9$k$H$-$Ke(B :invalid=>:replace e$B$r;XDj$7$?$H$-!"e(BUTF-32LE
e$B$He(B
[email protected]$7$/$J$$$b$N$,JV$C$F$-$^$9!#e(B

% ./ruby -ve ’
s = “\x80”.force_encoding(“utf-8”).encode(“utf-32le”,
:invalid=>:replace)
p s.encoding
p s.valid_encoding?
p s.bytesize
p s.force_encoding(“ascii-8bit”)
p s.force_encoding(“utf-32le”).valid_encoding?’
ruby 1.9.0 (2008-07-31 revision 18291) [i686-linux]
#Encoding:UTF-32LE
true
2
“\x00?”
false

“\x00?” e$B$Oe(B 2byte e$B$J$N$G!“e(BUTF-32LE
[email protected]$7$/$”$j$^$;$s!#e(B

e$B$"$H!"$D$$$G$K$$$&$H!"@5$7$/$J$$$K$b$+$+$o$i$:e(B
valid_encoding? e$B$Ge(B true e$B$,JV$C$F$-$^$9!#e(B

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs