cgi.rbのUTF-8対応について


#1

e$BF#2,$G$9!#e(B

cgi.rbe$B$G$Oe(BEUC-JPe$B$de(BShift_JISe$B$J$I$Oe(Bcharsete$B$r8+$Fe(B
e$B=PNO$rE,@Z$J%3!<%I$KJQ49$9$k$h$&$G$9$,!"e(B
e$B$3$l$Oe(BUTF-8e$B$K$OBP1~$7$F$$$J$$$h$&$G$9!#e(B
e$B%=!<%9$r8+$k$H!"e(BNKFe$B$GJQ49$7$F$$$k$@$1$N$h$&$G$9$N$G!e(B
e$B0J2<$N$h$&$Ke(BUTF-8e$B$K$bBP1~$7$F$$$F$$$?$@$1$k$He(B
e$B%=!<%9$re(BEUCe$B$G=q$$$F!=PNO$re(BUTF-8e$B$K$7$F$$$k?M$Oe(B
e$B9,$;$+$b$7$l$^$;$s!#$H;W$C$F=q$$$F$$^$7$?!#e(B
e$B$b$7!"e(BNKFe$B$,e(BUTF-8e$B$KBP1~$7$F$$$J$$>l9g$O$I$&$J$k$+$H$$$&$H!"e(B
e$B%F%9%H7k2L$Oe(Bwe$B%*%W%7%g%s$rL5;k$9$k$@$1$G$7$?$N$G!"e(B
NKFe$B$Ne(BUTF-8e$BBP1~$5$l$F$$$J$$%^%7%s$G$be(BUTF-8e$B$K$J$i$J$$$@$1$G!"e(B
e$BNc30$NH/@8$K$O$J$i$J$$$N$G!"LdBj$O5/$3$i$J$$$+$H;W$$$^$9!#e(B
Vine-2.6(ruby-1.6.7,nkf-1.92)e$B$G<B83$7$F$
$^$7$?!#e(B
e$B$$$+$,$G$7$g$&$+!#e(B

$ diff -uNr cgi.rb.org cgi.rb
cgi.rb.org 2005-10-01 00:01:11.000000000 +0900
+++ cgi.rb 2006-05-18 14:40:51.097041304 +0900
@@ -716,6 +716,9 @@
when /shift_jis/ni
content = NKF::nkf(-s, content)
options[language] = ja unless options.has_key?(language)

  •  when /utf-8/ni
    
  •    content = NKF::nkf('-w', content)
    
  •    options["language"] = "ja" unless options.has_key?("language")
     end
    
    end

#2

e$B4d7n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