NKF,Kconv

[email protected]>;3OB9-$G$9!#e(B

NKF::SJIS e$B$Oe(B #Encoding:Shift_JIS e$B$K$J$C$F$$$^$9$,!"e(B
-Ks e$B$KBP1~$9$k%(%s%3!<%G%#%s%0$re(B #Encoding:Windows-31J e$B$Ke(B
e$B$9$k$N$J$ie(B NKF::SJIS e$B$be(B #Encoding:Windows-31J
e$B$K$J$C$Fe(B
e$B$$$?J}$,NI$$$N$G$O$J$$$G$7$g$&$+e(B?

Kconv.tosjis e$B$H$+$G!#e(B

Kconv.isutf8 e$B$J$I$Ne(B Kconv.ise$B7O$G!Ve(Bincompatible encoding
regexp
matche$B!W$K$J$k$3$H$,$"$k$N$O;EMM$G$7$g$&$+e(B?

Kconv.isutf8("\u3042")
ArgumentError: incompatible encoding regexp match (ASCII-8BIT regexp
with UTF-8 string)

[email protected]@%$G$9!#e(B

Kazuhiro NISHIYAMA wrote:

NKF::SJIS e$B$Oe(B #Encoding:Shift_JIS e$B$K$J$C$F$$$^$9$,!"e(B
-Ks e$B$KBP1~$9$k%(%s%3!<%G%#%s%0$re(B #Encoding:Windows-31J e$B$Ke(B
e$B$9$k$N$J$ie(B NKF::SJIS e$B$be(B #Encoding:Windows-31J e$B$K$J$C$Fe(B
e$B$$$?J}$,NI$$$N$G$O$J$$$G$7$g$&$+e(B?

e$B$&!<$s!#!#!#e(B

  • SJIS e$B$Oe(B IANA e$BEPO?L>$G$O$J$$$+$ie(B Shift_JIS
    e$B0J30$r$5$7$F$b$$$$$+$be(B
  • Encoding::SJIS e$B$Oe(B Encoding::Shift_JIS e$B$Ne(B alias
    e$B$J$N$GL7=b$O$^$:$$e(B
    e$B$H$$$&$N$,8=;[email protected]$G$N9M$($G$9!#e(B

Kconv.tosjis e$B$H$+$G!#e(B

nkf -s e$B$Oe(B Windows-31J
e$B$K$7$F$7$^$$&$+$J$!$H;W$C$F$$$^$9!#$7$+$7!"e(Btosjis
e$B$Oe(B to SJIS [email protected]$m$&$J$!$H!#8D?ME
$K$O$`$7$me(B Windows-31J
e$BJQ49e(B + CRLF e$B2~9T$Ne(B
towin e$B$G$bDI2C$7$F$*Cc$rBy$=$&$+$J$!$H;W$C$F$$$^$9!#e(B

Kconv.isutf8 e$B$J$I$Ne(B Kconv.ise$B7O$G!Ve(Bincompatible encoding regexp
matche$B!W$K$J$k$3$H$,$"$k$N$O;EMM$G$7$g$&$+e(B?

Kconv.isutf8("\u3042")
ArgumentError: incompatible encoding regexp match (ASCII-8BIT regexp with UTF-8 string)

e$B%a%=%C%I$N<q;]$+$i$$$C$F%P%[email protected]$H;W$$$^$9!#0l1~e(Bstr.dup.force_encoding
(str.encoding) e$B$GD>$j$^$9$,!"e(BASCII-8BIT [email protected],I=8=$Oe(B
Shift_JIS e$B$de(B UTF-8
e$B$K$b%^%C%A$5$;$?$$$h$&$J!#$=$NJU$I$&$J$N$G$7$g$&$M!#e(B

In article [email protected],
“NARUSE, Yui” [email protected] writes:

e$B%a%=%C%I$N<q;]$+$i$$$C$F%P%[email protected]$H;W$$$^$9!#0l1~e(Bstr.dup.force_encoding
(str.encoding) e$B$GD>$j$^$9$,!"e(BASCII-8BIT [email protected],I=8=$Oe(B Shift_JIS e$B$de(B UTF-8
e$B$K$b%^%C%A$5$;$?$$$h$&$J!#$=$NJU$I$&$J$N$G$7$g$&$M!#e(B

e$B$=$NMW5a$O$9$G$K2?2s$+$"$C$F!"$I$&$bDA$7$/$J$$$h$&$G$9$,!“J8e(B
e$B;z$NH>J,$H$+$K%^%C%A$5$l$k$He(B MatchData#begin e$B$”$?$j$,Dj5A$Ge(B
e$B$-$J$$$N$G!“Cf?H$N%P%$%HNs$r07$$$?$$$N$G$”$l$P$"$-$i$a$Fe(B
str.dup.force_encoding(“ASCII-8BIT”) e$B$7$F$/[email protected]$5$$!#e(B

[email protected]!"$3$l$O%a%=%C%I$N<q;]$,J8;zNs$r%P%$%HNs$H$7$F2r<a$9$k$He(B
e$B$$$&[email protected]$C$?>l9g$G$9!#$b$7$=$&$$$&<q;]$G$"$l$P!"e(B
force_encoding e$B$r;H$&$N$O$=$N<q;][email protected]$H$$$($k$G$7$ge(B
e$B$&!#e(B

e$B$7$+$7!"0z?t$K$O%P%$%HNs$re(B ASCII-8BIT
e$B$JJ8;zNs$H$7$FEO$9$3$H!"e(B
e$B$H$$$&;EMM$K$9$l$P!"JQ99$NI,MW$O$J$$$N$+$b$7$l$^$;$s!#e(B

e$B$^$?!“Nc$($P!”%P%$%HNs$,e(B ISO-8859-1 e$B$KBP1~$7$Fe(B UTF-8
e$B$KJQ49e(B
e$B$5$l$?$b$N$r9M$($F85$N%P%$%HNs$r07$$$?$$$H$$$&$N$G$"$l$P$=$le(B
e$B$O$=$l$G0c$C$?J}K!$,I,MW$G$7$g$&!#e(B

e$B7k6I!"%P%$%HNs$r$I$&I=8=$7$F%a%=%C%I$KEO$9$+$H$$$&;EMM$NLdBje(B
e$B$K$J$j$^$9!#$D$^$j!“e(BString e$B$,%P%$%HNs$+$iJ8;zNs$KJQ$o$C$F$7e(B
e$B$^$C$?$N$G!”$=$l$KBP1~$7$?;EMM$r8!F$$7$J$1$l$P$J$i$J$$$H$$$&e(B
e$B$3$H$G$7$g$&!#e(B

[email protected]@%$G$9!#e(B

Tanaka A. wrote:

str.dup.force_encoding(“ASCII-8BIT”) e$B$7$F$/[email protected]$5$$!#e(B
e$B$3$l<+BN$OG<[email protected]$G$-$k$N$G$9$,!"%^%C%A$5$;$F<[email protected]$1$J$N$Ke(Bdupe$B$9$k$N$,$Je(B
e$B$s$+L5BL$J5$$,$9$k$N$,0z$C3][email protected]$G$7$g$&$+!#e(BASCII-8BIT
[email protected],I=8=$re(B
e$B%^%C%A$5$;$k$N$O!“J8;zNs$r%P%$%J%j$H2r<a$7$F%^%C%A$9$k$H$$$&<q;]$G$”$k$He(B
e$B2r<a$7$F!“0EL[$Ke(Bdup.force_encoding(“ASCII-8BIT”)
e$B$G$-$^$;$s$+$M!#e(B
e$B!Ve(BMatchData#begin
e$B$”$?$j$,Dj5A$G$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

e$B7k6I$N$H$3$m!"e(BString#valid_encoding?
e$B$r;H$C$F$/[email protected]$5$$$H$$$&$3$H$G!"e(B
Kconv.is* e$B$OA4GQ$G$$$$5$$b$7$F$$$k$N$G$9$h$Me(B

[email protected]@%$G$9!#e(B

Tanaka A. wrote:

force_encoding e$B$OJ8;z$H$$$&Cj>]$rGK$k$b$N$G$9$+$i!"0EL[$K$Oe(B
e$B$d$i$J$$$[$&$,$$$$$G$7$g$&!#e(B

e$B$"$H$O!"e(Bdup e$B$O%a%b%j$r6&M-$9$k$H;W$($P5$$K$J$i$J$/$J$j$^$;$s$+!#e(B

e$B$"!<!"$=$&$$$($P<BBN$OF1$8$G$9$M!#AGD>$Ke(B force_encoding
e$B$7$F$*$-$^$9!#e(B

In article [email protected],
“NARUSE, Yui” [email protected] writes:

e$B$3$l<+BN$OG<[email protected]$G$-$k$N$G$9$,!"%^%C%A$5$;$F<[email protected]$1$J$N$Ke(Bdupe$B$9$k$N$,$Je(B
e$B$s$+L5BL$J5$$,$9$k$N$,0z$C3][email protected]$G$7$g$&$+!#e(BASCII-8BIT [email protected],I=8=$re(B
e$B%^%C%A$5$;$k$N$O!“J8;zNs$r%P%$%J%j$H2r<a$7$F%^%C%A$9$k$H$$$&<q;]$G$”$k$He(B
e$B2r<a$7$F!"0EL[$Ke(Bdup.force_encoding(“ASCII-8BIT”) e$B$G$-$^$;$s$+$M!#e(B

e$B0EL[$Ke(B force_encoding e$B$H$$$&$N$O!"$J$s$Ge(B force_encoding
e$B$,$3e(B
e$B$s$J$KD9$/[email protected]<(E*$J$N$+$H$$$&M}M3$KH?$7$^$9!#e(B

force_encoding e$B$OJ8;z$H$$$&Cj>]$rGK$k$b$N$G$9$+$i!"0EL[$K$Oe(B
e$B$d$i$J$$$[$&$,$$$$$G$7$g$&!#e(B

e$B$"$H$O!"e(Bdup
e$B$O%a%b%j$r6&M-$9$k$H;W$($P5$$K$J$i$J$/$J$j$^$;$s$+!#e(B

e$B!Ve(BMatchData#begin e$B$"$?$j$,Dj5A$G$-$J$$!W$H$$$&$N$bJV$9J8;zNs$re(B
ASCII-8BIT e$B$K$9$l$P2sHr$G$-$k$h$&$J5$$,$9$k$N$G$9$,!#e(B

e$B$I$s$JDj5A$G$b$h$1$l$PDj5A$O$G$-$^$9!#$G$b!"[email protected]<A$,2ue(B
e$B$l$^$9$h$M!#85$NJ8;zNs$K$O4^$^$l$J$$J8;zNs$,e(B $& e$B$K=P$F$/$k$He(B
e$B$+!#e(B(e$B%P%$%HNs$H$7$F$O4^$^$l$F$k$G$7$g$&$,J8;zNs$H$7$F$Oe(B)

dup e$B$,L5BL$H$$$&M}M3$G;EMM$rOD$a$k$N$O$+$J$jK\KvE>E]$J$h$&$Ke(B
e$B;W$$$^$9!#e(B

e$B7k6I$N$H$3$m!"e(BString#valid_encoding? e$B$r;H$C$F$/[email protected]$5$$$H$$$&$3$H$G!"e(B
Kconv.is* e$B$OA4GQ$G$$$$5$$b$7$F$$$k$N$G$9$h$Me(B

e$B$^$!!"$=$l$b$R$H$D$NJ}K!$+$b$7$l$^$;$s!#e(B

e$B$^$?!“Cf?H$r$=$&$9$k$H$$$&$N$b$”[email protected]$k$+$b$7$l$^$;$s!#e(B
force_encoding e$B$OI,MW$G$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