_dump and encoding with marshal

e$B0J2<$N$h$&$K!"e(Bmarshal e$B;~$Ke(B _dump e$B$,e(B EUC-JP e$B$Je(B
String e$B$rJV$7e(B
e$B$?>l9g!"e(B_load e$B$G<u$1<h$ke(B String e$B$O%(%s%3!<%G%#%s%0$,e(B
ASCII-8BIT e$B$KJQ2=$7$F$$$^$9!#e(B

% ./ruby -ve ’
class C
def _dump(limit)
s1 = “\xa4\xa4”.force_encoding(“euc-jp”)
p [s1, s1.encoding]
s1
end
def self._load(s2)
p [s2, s2.encoding]
C.new
end
end
o1 = C.new
m = Marshal.dump(C.new)
p m
Marshal.load(m)

ruby 1.9.0 (2008-01-26 revision 15237) [i686-linux]
[“e$B$$e(B”, #Encoding:EUC-JP]
“\x04\bIu:\x06C\a\xA4\xA4\x00”
["\xA4\xA4", #Encoding:ASCII-8BIT]

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