Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

$B%5%V%8%'%/%HMs$N@8#J#I#SEj9F;~$NLdBjE@(B(Re: get out !!! (Re: ))

7 views
Skip to first unread message

Shuichi ICHIKAWA / 市川周一

unread,
Apr 26, 1996, 3:00:00 AM4/26/96
to

Subjectにiso-2022-jp(≒JISの日本語)を入れることについて、
(1) 対応していないnewsreaderがある
(2) 転送経路でESCが落ちると読めない
rjisがあれば読めるが持っていない人もいる
というような話が出ているようですが……

現状の話は他の方に任せて、私は別な方向から話をします。

そもそも(2)はrjisのロジックをnewsreaderに組み込めば解決(いや
回避)できる話ですよね。Subjectのiso-2022-jpに対応しているの
なら、「ESC落ちiso-2022-jp」に対応するというのは技術的に簡単
な話です。表示前にSubjectのバッファをrjisルーチンに通すだけ
ですから。現に私はそういう機能のpatchを作って使っていますの
で、ESCが落ちても全然気になりません。newsreaderではtinやktin
では既に対応patchが出ていますし、UMAではmush,elmあたりは対応
するpatchがあります。全てfj.sourcesに流れたりInternetで公開
されている筈です。折角こういう便利なものがあるのですから、有
志でこれらを普及していきましょう (^.^)

取り敢えずできること
・既に存在するpatchをもっと利用してもらう
・こうやって記事を書いて広報する
・他のnewsreaderへのportを進めてもらう
・ユーザも自発的により良いツールに乗り換える

newsreaderに関する話なのでFollowup-Toはfj.news.readerだけに
してあります。

参考
http://www.shimada.nuee.nagoya-u.ac.jp/~ichikawa/software.html

--
市川 周一 (Shuichi ICHIKAWA) <ichi...@nuee.nagoya-u.ac.jp>

Masaki Ishido

unread,
Apr 26, 1996, 3:00:00 AM4/26/96
to

いしどう%WinVN日本担当(^^;;@日本ヒューレット・パッカード です。

In article <4lpb34$4...@echonfs.echo.nuee.nagoya-u.ac.jp>, ichi...@nuee.nagoya-u.ac.jp says...


>取り敢えずできること
>・既に存在するpatchをもっと利用してもらう
>・こうやって記事を書いて広報する
>・他のnewsreaderへのportを進めてもらう
>・ユーザも自発的により良いツールに乗り換える

さっそく mmdec.c から rjis の部分を抜き出し、WinVN に組み込ませて
いただきました。ものの1時間もかからずに組み込むことができました。
# ESC 落ちで Subject が化けてた記事もちゃんと表示されて、ちょびっと
# 感動してます。
どうもありがとうございました。
次のバージョンからこの機能を含めさせていただきます。
--
Masaki Ishido
a Viola player
ish...@jpn.hp.com


Shuichi ICHIKAWA / 市川周一

unread,
Apr 30, 1996, 3:00:00 AM4/30/96
to

Masaki Ishido (ish...@jpn.hp.com) wrote:
:
: さっそく mmdec.c から rjis の部分を抜き出し、WinVN に組み込ませて

: いただきました。ものの1時間もかからずに組み込むことができました。
: # ESC 落ちで Subject が化けてた記事もちゃんと表示されて、ちょびっと
: # 感動してます。

そういえば、newsreaderにpatchを当てられない環境の人でも、C
コンパイラが使えれば mmdec を作って iso-2022-jp の ESC を復
活することができます。もちろんrjisを使えばいいのですが、単機
能であるぶんmmdecはrjisより小さいので、以下にsource(mmdec.c)
を添付します。

元々はmimeのbase64でencodeされたiso-2022-jp headerをdecodeす
るためのものです。-rをつけるとiso-2022-jpのESCを復活します。
以前fj.sourcesに流したと思いますが……

--
市川 周一 (Shuichi ICHIKAWA) <ichi...@nuee.nagoya-u.ac.jp>

-- mmdec.c follows --
/*
* ISO-2022-JP handling routines
* &
* MIME decode routines (quick hack just for ISO-2022-JP)
*
* Thu Jan 25 10:11:42 JST 1996
*
* Copyright (C) 1994, 1995, 1996
* Shuichi Ichikawa (ichi...@nuee.nagoya-u.ac.jp)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either versions 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with SKK, see the file COPYING. If not, write to the Free
* Software Foundation Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include <stdio.h>
#include <string.h>

/*
* MIME decoding routines
*
* Written by S. Ichikawa,
* partially inspired by encdec.c of <j...@efd.lth.se>.
*/
#define BUFLEN 1024
#define ESC (0x1b)

static char mm64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" ;
static char mmquote[] = "0123456789ABCDEF";
static int mmcont = 0;

void
mmdec_base64(t, s)
char *t, *s;
{
int d, count, j, val;
char buf[BUFLEN], *bp, nw[4], *p;

for (bp = buf; *s; s += 4) {
val = 0;
if (s[2] == '=') count = 1;
else if (s[3] == '=') count = 2;
else count = 3;

for (j = 0; j <= count; j++) {
if (!(p = strchr(mm64, s[j]))) {
return;
}
d = p - mm64;
d <<= (3-j)*6;
val += d;
}
for (j = 2; j >= 0; j--) {
nw[j] = val & 255;
val >>= 8;
}
if (count--) *bp++ = nw[0];
if (count--) *bp++ = nw[1];
if (count) *bp++ = nw[2];
}
*bp = '\0';
strcpy(t, buf);
}

void
mmdec_quote(t, s)
char *t, *s;
{
char buf[BUFLEN], cval, *bp, *p;

for (bp = buf; *s; ) {
if (*s == '=') {
cval = 0;
if (s[1] && (p = strchr(mmquote, s[1]))) {
cval += (p - mmquote);
} else {
*bp++ = *s++;
continue;
}
if (s[2] && (p = strchr(mmquote, s[2]))) {
cval <<= 4;
cval += (p - mmquote);
*bp++ = cval;
s += 3;
} else {
*bp++ = *s++;
}
} else if (*s == '_') {
*bp++ = 0x20;
s++;
} else {
*bp++ = *s++;
}
}
*bp = '\0';
strcpy(t, buf);
}

void
mmdecode(trg, str)
char *trg, *str;
{
char buf[BUFLEN], mmbuf[BUFLEN];
char *s, *t, *u;
int base64, quote;

buf[0] = '\0';

for (s = str, u = buf; *s; ) {
if (!strncasecmp(s, "=?ISO-2022-JP?B?", 16)) {
base64 = 1;
} else {
base64 = 0;
}
if (!strncasecmp(s, "=?ISO-2022-JP?Q?", 16)) {
quote = 1;
} else {
quote = 0;
}
if (base64 || quote) {
if (mmcont) {
for (t = s - 1;
t >= str && (*t == ' ' || *t == '\t'); t--) {
u--;
}
}
for (s += 16, t = mmbuf; *s; ) {
if (s[0] == '?' && s[1] == '=') {
break;
} else {
*t++ = *s++;
}
}
if (s[0] != '?' || s[1] != '=') {
goto end;
} else {
s += 2;
*t = '\0';
}
if (base64) mmdec_base64(mmbuf, mmbuf);
if (quote) mmdec_quote(mmbuf, mmbuf);
for (t = mmbuf; *t; ) *u++ = *t++;
mmcont = 1;
/* if (*s == ' ' || *s == '\t') *u++ = *s; */
/* for ( ; *s == ' ' || *s == '\t'; s++) ; */
} else {
if (*s != ' ' && *s != '\t') mmcont = 0;
*u++ = *s++;
}
}
*u = '\0';
end:
strcpy(trg, buf);
}

int
main(ac, av)
int ac;
char **av;
{
FILE *fp;
char buf[BUFLEN];
char header = 1, body = 0, r_jis = 0;
int i, c;

for (i = 1; i < ac; i++) {
if (strcmp(av[i], "-B") == NULL) body = 1;
else if (strcmp(av[i], "-r") == NULL) r_jis = 1;
else break;
}

if (i >= ac) {
fp = stdin;
} else {
if ((fp = fopen(av[i], "r")) == NULL) {
fprintf(stderr, "%s: cannot open %s\n", av[0], av[i]);
exit(1);
}
}

while (fgets(buf, BUFLEN, fp)) {
if (buf[0] == '\n' && buf[1] == '\0') header = 0;
if (header) {
c = fgetc(fp);
if (c == ' ' || c == '\t') {
buf[strlen(buf)-1] = '\0';
ungetc(c, fp);
} else {
ungetc(c, fp);
}
}
if (header || body) mmdecode(buf, buf);
if (r_jis) rjis(buf, buf);
fprintf(stdout, "%s", buf);
}

close(fp);
exit(0);
}

/*
* Insert ESC where it seems lost.
* (The author of this function "rjis" is S. Ichikawa.)
*/
int
rjis(t, s)
char *t, *s;
{
char *p, buf[BUFLEN];
int kanji = 0;

if (strchr(s, ESC) || !strchr(s, '$')) {
if (s != t) strcpy(t, s);
return 1;
}
for (p = buf; *s; ) {
if (!kanji && s[0] == '$' && (s[1] == '@' || s[1] == 'B')) {
if (maybekanji((int)s[2], (int)s[3])) {
kanji = 1;
*p++ = ESC;
*p++ = *s++;
*p++ = *s++;
*p++ = *s++;
*p++ = *s++;
continue;
}
*p++ = *s++;
continue;
}
if (kanji && s[0] == '(' && (s[1] == 'J' || s[1] == 'B')) {
kanji = 0;
*p++ = ESC;
*p++ = *s++;
*p++ = *s++;
continue;
}
*p++ = *s++;
}
*p = *s; /* terminate string */

strcpy(t, buf);
return 0;
}

/*
* The following function "maybekanji" is derived from
* RJIS-1.0 by Mr. Hironobu Takahashi.
* Maybekanji() is included here under the courtesy of the author.
* The original comment of rjis.c is also included here.
*/

/*
* RJIS ( Recover JIS code from broken file )
* $Header: rjis.c,v 0.2 92/09/04 takahasi Exp $
* Copyright (C) 1992 1994
* Hironobu Takahashi (taka...@tiny.or.jp)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either versions 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with SKK, see the file COPYING. If not, write to the Free
* Software Foundation Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

int maybekanji(c1, c2)
int c1;
int c2;
{

if ((c2 < 33) || (c2 > 126)) return 0;
if ((c1 < 33) || ((40 < c1) && (c1 < 48)) || (116 < c1)) return 0;
c2 -= 32;
switch(c1-32) {
case 2:
if ((14 < c2) && ( c2 < 26)) return 0;
if ((33 < c2) && ( c2 < 42)) return 0;
if ((48 < c2) && ( c2 < 60)) return 0;
if ((74 < c2) && ( c2 < 82)) return 0;
if ((89 < c2) && ( c2 < 94)) return 0;
break;
case 3:
if (c2 < 16) return 0;
if ((25 < c2) && ( c2 < 33)) return 0;
if ((58 < c2) && ( c2 < 65)) return 0;
if (90 < c2) return 0;
break;
case 4:
if (83 < c2) return 0;
break;
case 5:
if (86 < c2) return 0;
break;
case 6:
if ((24 < c2) && ( c2 < 33)) return 0;
if (56 < c2) return 0;
break;
case 7:
if ((33 < c2) && ( c2 < 49)) return 0;
if (81 < c2) return 0;
break;
case 8:
if (32 < c2) return 0;
break;
case 47:
if (51 < c2) return 0;
break;
case 84:
if (6 < c2) return 0;
break;
}
return 1;
}


0 new messages