{"id":115,"date":"2004-11-18T00:47:17","date_gmt":"2004-11-17T15:47:17","guid":{"rendered":"http:\/\/bae2.s157.xrea.com\/?p=115"},"modified":"2004-11-18T00:47:17","modified_gmt":"2004-11-17T15:47:17","slug":"rss%e5%8f%96%e5%be%97%e5%be%8c%e3%82%a8%e3%83%b3%e3%82%b3%e3%83%bc%e3%83%89%e5%a4%89%e6%9b%b4cgi","status":"publish","type":"post","link":"https:\/\/randt.jp\/?p=115","title":{"rendered":"RSS\u53d6\u5f97\u5f8c\u30a8\u30f3\u30b3\u30fc\u30c9\u5909\u66f4CGI"},"content":{"rendered":"<p>The T World \u306f UTF-8 \u3067\u51fa\u529b\u3057\u3066\u3044\u308b\u305f\u3081\u3001MTRSSFeed\u3092\u4f7f\u7528\u3059\u308b\u518d\u3001\u30bd\u30fc\u30b9\u3068\u306a\u308bRDF\u30d5\u30a1\u30a4\u30eb\u306e\u30a8\u30f3\u30b3\u30fc\u30c9\u3082UTF-8\u306e\u3082\u306e\u3057\u304b\u6b63\u3057\u304f\u8868\u793a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u306a\u304b\u3063\u305f\u3002\u305d\u3053\u3067\u3001Ruby\u3092\u3064\u304b\u3063\u3066\u7c21\u5358\u306aCGI\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4f5c\u6210\u3057\u3001CGI\u5b9f\u884c\u6642\u306b\u6700\u65b0\u306eRDF\u30d5\u30a1\u30a4\u30eb\u3092\u53d6\u5f97\u3057\u3066UTF-8\u306b\u5909\u66f4\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u307f\u305f\u3002<\/p>\n<table border=\"1\">\n<tr>\n<th>\u30d5\u30a1\u30a4\u30eb\u540d<\/th>\n<td>getrss.rb<\/td>\n<\/tr>\n<tr>\n<th>\u5f15\u6570<\/th>\n<td>rss:\u30bd\u30fc\u30b9\u3068\u306a\u308bRDF\u30d5\u30a1\u30a4\u30eb\u306eURI<br \/>\nie:\u30bd\u30fc\u30b9RDF\u30d5\u30a1\u30a4\u30eb\u306e\u30a8\u30f3\u30b3\u30fc\u30c9<br \/>\noe:\u51fa\u529b\u3059\u308b\u30a8\u30f3\u30b3\u30fc\u30c9<\/td>\n<\/tr>\n<tr>\n<th>\u4f7f\u7528\u4f8b<\/th>\n<td>getrss.rb?http:\/\/www.randt.jp\/index.rdf?ie=UTF-8?oe=UTF-8<\/td>\n<\/tr>\n<\/table>\n<p><!--more--><\/p>\n<pre>\n#!\/usr\/bin\/ruby\n##!\/usr\/local\/bin\/ruby\nabout = 'Made by bae $Id: getrss.rb,v 1.1 2004\/11\/17 15:08:14 tohru_i Exp $'\n\nrequire 'cgi'\nrequire 'net\/http'\nrequire 'iconv'\nrequire 'uri'\nrequire 'rexml\/document'\n\narg = CGI.new\n\nsrcuri = arg['rss']\nif srcuri == \"\"\n    p \"Content-type: text\/htmlnn\"\n    p about\n    p \"Invalid arguments\"\n    exit 0\nend\n\nie = arg['ie']\nif ie == \"\"\n    ie = 'UTF-8'\nend\n\noe = arg['oe']\nif oe == \"\"\n    oe = 'UTF-8'\nend\n\nuri = URI.split(srcuri)\nresbody = ''\nNet::HTTP.version_1_2\nNet::HTTP.start(uri[2], uri[3]) {|http|\n    begin\n        resdata = http.get(uri[5])\n        resbody = resdata.body\n    rescue => ioerr\n        p 'Content-type text\/htmlnn'\n        p \"Exception caught!\"\n        p ioerr\n        exit 0\n    end\n}\n\nbegin\n    document = REXML::Document.new(resbody)\n    xmldecl = document.xml_decl\n    xmldecl.encoding = oe\nrescue =>rescueDoc\n    p 'Content-type text\/htmlnn'\n    p \"Exception caught!\"\n    p about\n    puts rescueDoc.success\n    exit 0\nend\n\nbegin\n    puts \"Content-type: text\/xmlnn\"\n    puts Iconv::iconv(oe, 'UTF-8', document.to_s)\nrescue =>rescuedoc\n    p \"Content-type: text\/htmlnn\"\n    p \"Exception caught!\"\n    p about\n    p rescuedoc\n    exit 0\nend\n<\/pre>\n<p>rexml\u3092\u4f7f\u7528\u3057\u3066\u3044\u308b\u304c\u3001rexml\u5185\u3067UTF-8\u306b\u5f37\u5236\u7684\u306b\u5909\u63db\u3057\u3066\u3044\u308b\u3088\u3046\u306b\u601d\u308f\u308c\u308b\u3002\u307e\u305f\u3001Iconv\u306f UTF-8 \u304b\u3089 EUC-JP, ISO-2022-JP \u306e\u5909\u63db\u3067\u307b\u3068\u3093\u3069\u306e\u5834\u5408Exception\u3092\u51fa\u3059\u3002\u3057\u305f\u304c\u3063\u3066\u3001\u4f5c\u308a\u7684\u306b\u306fINPUT\/OUTPUT\u306f\u81ea\u7531\u306b\u30a8\u30f3\u30b3\u30fc\u30c9\u3092\u6307\u5b9a\u3067\u304d\u308b\u3088\u3046\u306b\u898b\u3048\u308b\u304c\u3001OUTPUT\u306fUTF-8\u3057\u304b\u5b9f\u7528\u306b\u8010\u3048\u306a\u3044\u3002\u3053\u306e\u8fba\u308a\u306f\u6b8b\u4ef6\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The T World \u306f UTF-8 \u3067\u51fa\u529b\u3057\u3066\u3044\u308b\u305f\u3081\u3001MTRSSFeed\u3092\u4f7f\u7528\u3059\u308b\u518d\u3001\u30bd\u30fc\u30b9\u3068\u306a\u308bRDF\u30d5\u30a1\u30a4\u30eb\u306e\u30a8\u30f3\u30b3\u30fc\u30c9\u3082UTF-8\u306e\u3082\u306e\u3057\u304b\u6b63\u3057\u304f\u8868\u793a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u306a\u304b\u3063\u305f\u3002\u305d\u3053\u3067\u3001Ruby\u3092\u3064\u304b\u3063\u3066\u7c21\u5358\u306aC &#8230;<\/p>\n<p> <a class=\"continue-reading-link\" href=\"https:\/\/randt.jp\/?p=115\"><span>Continue reading<\/span><i class=\"crycon-right-dir\"><\/i><\/a> <\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,18,19],"tags":[],"class_list":["post-115","post","type-post","status-publish","format-standard","hentry","category-blog","category-18","category-19"],"_links":{"self":[{"href":"https:\/\/randt.jp\/index.php?rest_route=\/wp\/v2\/posts\/115","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/randt.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/randt.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/randt.jp\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/randt.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=115"}],"version-history":[{"count":0,"href":"https:\/\/randt.jp\/index.php?rest_route=\/wp\/v2\/posts\/115\/revisions"}],"wp:attachment":[{"href":"https:\/\/randt.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randt.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randt.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}