2008-07-06 :-)
_ [tDiary][grep.rb][UTF-8]tdiary grep.rb を UTF-8 化する
たんに euc を utf8 に変えただけであり超ばーたりーである。
--- /home/rin/public_html/tdiary/grep.rb 2007-05-10 19:18:27.000000000 +0900
+++ /home/rin/public_html/tdiary-trunk/grep.rb 2008-07-06 18:06:22.000000000 +0900
@@ -26,7 +26,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="ja-JP">
<head>
- <meta http-equiv="Content-Type" content="text/html; charset=euc-jp">
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Language" content="ja-JP">
<title>tDiary Grep</title>
</head>
@@ -117,12 +117,12 @@
begin
return Uconv.u8toeuc(str)
rescue Uconv::Error
- return NKF::nkf('-e -m0', str)
+ return NKF::nkf('-w -m0', str)
end
end
rescue LoadError
def to_euc(str)
- NKF::nkf('-e -m0', str)
+ NKF::nkf('-w -m0', str)
end
end
@@ -140,7 +140,7 @@
BEGIN { $defout.binmode }
def main
- $KCODE = 'EUC'
+ $KCODE = 'UTF8'
cgi = CGI.new
html = '<html><head><title></title></head><body><p>error</p></body></html>'
begin
@@ -185,7 +185,7 @@
def send_html(cgi, html)
print cgi.header('status' => '200 OK',
'type' => 'text/html',
- 'charset' => 'euc-jp',
+ 'charset' => 'UTF-8',
'Content-Length' => html.length.to_s,
'Cache-Control' => 'no-cache',
'Pragma' => 'no-cache')
_ [ruby][世界のナベアツ]世界のナベアツ 3 の倍数と 3 がつく数字のときにアホ
こうですかよくわかりません。
#!/usr/pkg/bin/ruby
def aho?( num )
if( num % 3 ) == 0
return true
end
return num.to_s.include?('3')
end
def main(arg)
1.upto(arg[0].to_i) { |n|
if aho?(n) == true
puts "aho"
else
puts "#{n}"
end
}
end
main(ARGV)
% ./nabe00.rb 33 1 2 aho 4 5 aho 7 8 aho 10 11 aho aho 14 aho 16 17 aho 19 20 aho 22 aho aho 25 26 aho 28 29 aho aho aho aho
[ツッコミを入れる]















