This is KanjiUtil.c in view mode; [Download] [Up]
/* * IRC.app -- IRC client program for NEXTSTEP * Copyright (C)1995 Norihiro Itoh * * このソースはIRC.appの一部です。 * This file is part of IRC.app. * * 本プログラムはフリー・ソフトウェアです。あなたは、Free Software * Foundationが公表したGNU一般公有使用許諾の「バージョン2」或いは * それ以降の各バージョンの中からいずれかを選択し、そのバージョンが * 定める条項に従って本プログラムを再頒布または変更することができま * す。 * 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 version 2 of the License, or * (at your option) any later version. * * 本プログラムは有用とは思いますが、頒布にあたっては、市場性及び特 * 定目的適合性についての暗黙の保証を含めて、いかなる保証も行ないま * せん。詳細についてはGNU一般公有使用許諾書をお読みください。 * 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. * * あなたは、本プログラムと一緒にGNU一般公有使用許諾の写しを受け取っ * ているはずです。そうでない場合は、Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USAへ手紙を書いてください。 * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * 作者のメールアドレス: nito@scorpio.bekkoame.or.jp * Author's e-mail address: nito@scorpio.bekkoame.or.jp */ #import <string.h> #define ANSI_X_3_4_1986 "\033(B" #define JIS_X_0201_1976 "\033(J" #define JIS_X_0208_1978 "\033$@" #define JIS_X_0208_1983 "\033$B" #define EUC_SS2 0x8E #define EUC_SS3 0x8F int euc2jis(char *src, char *alt, int srcsize) { int sindex, aindex; int jflag; unsigned char c; jflag = 0; sindex = aindex = 0; while (sindex < srcsize) { c = *(src + sindex); if (c <= 0x7F) { if (jflag == 1) { bcopy(ANSI_X_3_4_1986, (alt + aindex), 3); jflag = 0; aindex += 3; } *(alt + aindex) = c; sindex++; aindex++; } else if (c <= EUC_SS2) { sindex += 2; aindex += 2; } else if ((c >= 0xA1) && (c <= 0xF4)) { if (jflag == 0) { bcopy(JIS_X_0208_1983, (alt + aindex), 3); jflag = 1; aindex += 3; } *(alt + aindex) = (c & 0x7F); *(alt + aindex + 1) = (*(src + sindex + 1) & 0x7F); sindex += 2; aindex += 2; } else { sindex += 2; } } if (jflag == 1) { bcopy(ANSI_X_3_4_1986, (alt + aindex), 3); jflag = 0; aindex += 3; } return aindex; } int jis2euc(char *src, char *alt, int srcsize) { int sindex, aindex; int jflag; unsigned char c; jflag = 0; sindex = aindex = 0; while (sindex < srcsize) { c = *(src + sindex); if (c == 0x1B) { if (bcmp((src + sindex), JIS_X_0208_1978, 3) == 0) { jflag = 1; sindex += 3; } else if (bcmp((src + sindex), JIS_X_0208_1983, 3) == 0) { jflag = 1; sindex += 3; } else if (bcmp((src + sindex), JIS_X_0201_1976, 3) == 0) { jflag = 0; sindex += 3; } else if (bcmp((src + sindex), ANSI_X_3_4_1986, 3) == 0) { jflag = 0; sindex += 3; } else { *(alt + aindex) = c; sindex++; aindex++; } } else if (c <= 0x7F) { if (jflag == 1) c += 0x80; *(alt + aindex) = c; sindex++; aindex++; } else { sindex++; } } return aindex; }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.