Distinguish "w" and "w:euc-jp"

EUC-JP e$B$J4D6-$G!"e(Bopen e$B$Ke(B “w”
e$B$rEO$7$FJQ49$,5/$-$J$$>l9g$He(B
“w:euc-jp” e$B$rEO$7$FJQ49$,5/$-$k>l9g$N0c$$$,e(B
external_encoding, internal_encoding e$B$G6hJL$G$-$^$;$s!#e(B

e$B0J2<$N$h$&$Ke(B “w” [email protected]$He(B \u6666 e$B$,JQ49$5$l$J$$$^$^e(B 3byte
e$B$G=PNOe(B
e$B$5$l$^$9$,!"e(B

% ./ruby -e ’
open(“zz”, “w”) {|f|
p f.external_encoding
p f.internal_encoding
f.print “\u6666”
}
p File.size(“zz”)

#Encoding:EUC-JP
nil
3

“w:euc-jp” [email protected]$HJQ49$5$l$Fe(B 2byte e$B$K$J$j$^$9!#e(B

% ./ruby -e ’
open(“zz”, “w:euc-jp”) {|f|
p f.external_encoding
p f.internal_encoding
f.print “\u6666”
}
p File.size(“zz”)

#Encoding:EUC-JP
nil
2

e$B$7$+$7!"e(Bextenral_encoding e$B$O$I$A$i$be(B EUC-JP e$B$G!"e(B
internal_encoding e$B$O$I$A$i$be(B nil e$B$G$9!#e(B

e$BJQ49$7$J$$$[$&$Ne(B external_encoding e$B$O$J$s$Ge(B EUC-JP
e$B$J$s$G$7$ge(B
e$B$&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