🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fj.editor.xemacs
Article #98

Re: open-network-stream使用時の文字コードについて

#98
From: Katsumi Yamaoka
Date: Fri, 19 Oct 2001 00:08
49 lines
3424 bytes
>>>>> In <xl9g08hwhle.wl@cal.infonets.hiroshima-u.ac.jp>
>>>>>	IMAI Hidetoshi <hidepin@infonets.hiroshima-u.ac.jp> wrote:

中治さん> 日本語と思われる部分が、すべて「~」になっています。

肝心な文字化け部分は "=8E=80" → "\216\200" → "死" のようですね。

今井さん> set-process-coding-systemの引数を
今井さん> sjis euc-japan shift_jis-dos automatic-conversion と
今井さん> いろいろためしてみましたが解決しませんでした。

特定の部分がデコードできない理由を想像してみるに、何回か
accept-process-output でデータを取り込むときに sjis の 2-byte の
途中で区切られてしまったんじゃないかしら。

今井さん> なお、shell-command-to-string を用いて fetch,nkf -eとしたと
今井さん> きは文字化けはおきませんでした。

それと同じことを elisp で行なうのが良いのではありませんか。すな
わち open-network-stream は無変換で動作させ、取り込み終わった後
でデコードする、と。

(defun nybc-get-log-file ()
  "ログファイルを取ってくる"
  (message "now connecting...")
  (save-excursion
    (set-buffer nybc-view-net-buffer)
    (erase-buffer)
    (let* ((coding-system-for-read 'binary)
	   (coding-system-for-write 'binary)
	   (proc (open-network-stream nybc-view-net-process
				      nybc-view-net-buffer
				      nybc-view-net-url
				      80)))
      (process-send-string
       proc
       (format "GET %s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\n\r\n"
	       "/hogehoge/keijiban.log"
	       nybc-view-net-url))
      (while (and (eq (process-status proc) 'open)
		  (goto-char (point-min))
		  (not (re-search-forward "^Process" nil t)))
	(accept-process-output proc)))
    (decode-coding-region (point-min) (point-max) 'shift_jis-dos))
  (message "now connecting...connected"))

"\r\n" は "\n" の方が良いかもしれません。適宜調整して下さい。
-- 
山岡
Technical Details
Message-ID: <yosu4rowqynv.fsf_-_@jpl.org>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!193.174.75.178!news-fra1.dfn.de!fu-berlin.de!uni-berlin.de!groundpoundrecords.COM!not-for-mail
References: <xl9g08hsdaq.wl@cal.infonets.hiroshima-u.ac.jp> <87ofn5wkb6.fsf@boggy.acest.tutrp.tut.ac.jp> <xl9g08hwhle.wl@cal.infonets.hiroshima-u.ac.jp>

Show Full Headers
Complete Article Headers
X-Google-Language: Japanese,JIS
X-Google-Thread: 1107f7,e1d71c6971fdc530
X-Google-Attributes: gid1107f7,public
X-Google-ArrivalTime: 2001-10-18 17:09:10 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!193.174.75.178!news-fra1.dfn.de!fu-berlin.de!uni-berlin.de!groundpoundrecords.COM!not-for-mail
From: Katsumi Yamaoka <yamaoka@jpl.org>
Newsgroups: fj.editor.xemacs
Subject: Re: open-network-stream使用時の文字コードについて
Date: Fri, 19 Oct 2001 09:08:35 +0900
Organization: Emacsen advocacy group
Lines: 49
Message-ID: <yosu4rowqynv.fsf_-_@jpl.org>
References: <xl9g08hsdaq.wl@cal.infonets.hiroshima-u.ac.jp>
 <87ofn5wkb6.fsf@boggy.acest.tutrp.tut.ac.jp>
 <xl9g08hwhle.wl@cal.infonets.hiroshima-u.ac.jp>
NNTP-Posting-Host: groundpoundrecords.com (207.228.244.150)
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-2022-jp
X-Trace: fu-berlin.de 1003450148 26741910 207.228.244.150 (16 [27265])
X-Orig-Path: yamaoka
User-Agent: Gnus/5.090004 (Oort Gnus v0.04) XEmacs/21.5 (asparagus)
 Mule-UCS/0.84 (KOUGETSUDAI:向月台)
X-Face: #kKnN,xUnmKia.'[pp`;Omh}odZK)?7wQSl"4o04=EixTF+V[""w~iNbM9ZL+.b*_CxUmFk
 B#Fu[*?MZZH@IkN:!"\w%I_zt>[$nm7nQosZ<3eu;B:$Q_:p!',P.c0-_Cy[dz4oIpw0ESA^D*1Lw=
 L&i*6&(