Blame WWW/Library/Implementation/HTCJK.h

Packit f574b8
/*
Packit f574b8
 * $LynxId: HTCJK.h,v 1.19 2012/08/15 23:11:03 tom Exp $
Packit f574b8
 *
Packit f574b8
 *			CJK character converter		HTCJK.h
Packit f574b8
 *			=======================
Packit f574b8
 *
Packit f574b8
 *	Added 11-Jun-96 by FM, based on jiscode.h for
Packit f574b8
 *	  Yutaka Sato's (ysato@etl.go.jp) SJIS.c, and
Packit f574b8
 *	  Takuya ASADA's (asada@three-a.co.jp) CJK patches.
Packit f574b8
 *	  (see SGML.c).
Packit f574b8
 *
Packit f574b8
 */
Packit f574b8
Packit f574b8
#ifndef HTCJK_H
Packit f574b8
#define HTCJK_H
Packit f574b8
Packit f574b8
#ifndef HTUTILS_H
Packit f574b8
#include <HTUtils.h>
Packit f574b8
#endif
Packit f574b8
Packit f574b8
#ifdef __cplusplus
Packit f574b8
extern "C" {
Packit f574b8
#endif
Packit f574b8
/*
Packit f574b8
 *	STATUS CHANGE CODES
Packit f574b8
 */
Packit f574b8
#define TO_2BCODE	'$'
Packit f574b8
#define TO_1BCODE	'('
Packit f574b8
#define TO_KANA		'\016'
Packit f574b8
#define TO_KANAOUT	'\017'
Packit f574b8
#define TO_KANJI	"\033$B"
Packit f574b8
#define TO_HANJI	"\033$A"
Packit f574b8
#define TO_HANGUL	"\033$(C"
Packit f574b8
#define TO_ASCII	"\033(B"
Packit f574b8
#define IS_SJIS_LO(lo)	((0x40<=lo)&&(lo!=0x7F)&&(lo<=0xFC))
Packit f574b8
#define IS_SJIS_HI1(hi) ((0x81 <= (hi)) && ((hi) <= 0x9F))	/* 1st lev. */
Packit f574b8
#define IS_SJIS_HI2(hi) ((0xE0 <= (hi)) && ((hi) <= 0xEF))	/* 2nd lev. */
Packit f574b8
#define IS_SJIS(hi,lo,in_sjis) (!IS_SJIS_LO(lo)?0:IS_SJIS_HI1(hi)?(in_sjis=1):in_sjis&&IS_SJIS_HI2(hi))
Packit f574b8
#define IS_SJIS_2BYTE(hi,lo) (IS_SJIS_LO(lo)&&(IS_SJIS_HI1(hi)||IS_SJIS_HI2(hi)))
Packit f574b8
#define IS_SJIS_X0201KANA(lo) ((0xA1<=lo)&&(lo<=0xDF))
Packit f574b8
#define IS_EUC_LOX(lo)	((0xA1<=lo)&&(lo<=0xFE))	/* extended */
Packit f574b8
#define IS_EUC_HI(hi)	((0xA1<=hi)&&(hi<=0xFE))
Packit f574b8
#define IS_EUC_X0201KANA(hi,lo) ((hi==0x8E)&&(0xA1<=lo)&&(lo<=0xDF))
Packit f574b8
#define IS_EUC(hi,lo) ((IS_EUC_HI(hi) && IS_EUC_LOX(lo))||IS_EUC_X0201KANA(hi,lo))
Packit f574b8
#define IS_JAPANESE_2BYTE(hi,lo) (IS_SJIS_2BYTE(hi,lo) || IS_EUC(hi,lo))
Packit f574b8
#define IS_BIG5_LOS(lo)	((0x40<=lo)&&(lo<=0x7E))	/* standard */
Packit f574b8
#define IS_BIG5_LOX(lo)	((0xA1<=lo)&&(lo<=0xFE))	/* extended */
Packit f574b8
#define IS_BIG5_HI(hi)	((0xA1<=hi)&&(hi<=0xFE))
Packit f574b8
#define IS_BIG5(hi,lo) (IS_BIG5_HI(hi) && (IS_BIG5_LOS(lo) || IS_BIG5_LOX(lo)))
Packit f574b8
    typedef enum {
Packit f574b8
	NOKANJI = 0, EUC, SJIS, JIS
Packit f574b8
    } HTkcode;
Packit f574b8
    typedef enum {
Packit f574b8
	NOCJK = 0, JAPANESE, CHINESE, KOREAN, TAIPEI
Packit f574b8
    } HTCJKlang;
Packit f574b8
Packit f574b8
    extern HTCJKlang HTCJK;
Packit f574b8
Packit f574b8
/*
Packit f574b8
 *  Function prototypes.
Packit f574b8
 */
Packit f574b8
    extern void JISx0201TO0208_EUC(unsigned IHI,
Packit f574b8
				   unsigned ILO,
Packit f574b8
				   unsigned char *OHI,
Packit f574b8
				   unsigned char *OLO);
Packit f574b8
Packit f574b8
    extern unsigned char *SJIS_TO_JIS1(unsigned HI,
Packit f574b8
				       unsigned LO,
Packit f574b8
				       unsigned char *JCODE);
Packit f574b8
Packit f574b8
    extern unsigned char *JIS_TO_SJIS1(unsigned HI,
Packit f574b8
				       unsigned LO,
Packit f574b8
				       unsigned char *SJCODE);
Packit f574b8
Packit f574b8
    extern unsigned char *EUC_TO_SJIS1(unsigned HI,
Packit f574b8
				       unsigned LO,
Packit f574b8
				       register unsigned char *SJCODE);
Packit f574b8
Packit f574b8
    extern void JISx0201TO0208_SJIS(unsigned I,
Packit f574b8
				    unsigned char *OHI,
Packit f574b8
				    unsigned char *OLO);
Packit f574b8
Packit f574b8
    extern unsigned char *SJIS_TO_EUC1(unsigned HI,
Packit f574b8
				       unsigned LO,
Packit f574b8
				       unsigned char *EUCp);
Packit f574b8
Packit f574b8
    extern unsigned char *SJIS_TO_EUC(unsigned char *src,
Packit f574b8
				      unsigned char *dst);
Packit f574b8
Packit f574b8
    extern unsigned char *EUC_TO_SJIS(unsigned char *src,
Packit f574b8
				      unsigned char *dst);
Packit f574b8
Packit f574b8
    extern unsigned char *EUC_TO_JIS(unsigned char *src,
Packit f574b8
				     unsigned char *dst,
Packit f574b8
				     const char *toK,
Packit f574b8
				     const char *toA);
Packit f574b8
Packit f574b8
    extern unsigned char *TO_EUC(const unsigned char *jis,
Packit f574b8
				 unsigned char *euc);
Packit f574b8
Packit f574b8
    extern void TO_SJIS(const unsigned char *any,
Packit f574b8
			unsigned char *sjis);
Packit f574b8
Packit f574b8
    extern void TO_JIS(const unsigned char *any,
Packit f574b8
		       unsigned char *jis);
Packit f574b8
Packit f574b8
    extern char *str_kcode(HTkcode code);
Packit f574b8
Packit f574b8
#ifdef __cplusplus
Packit f574b8
}
Packit f574b8
#endif
Packit f574b8
#endif				/* HTCJK_H */