⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 euctotc.c

📁 T-kernel 的extension源代码
💻 C
字号:
/* *---------------------------------------------------------------------- *    T-Kernel / Standard Extension * *    Copyright (C) 2006 by Ken Sakamura. All rights reserved. *    T-Kernel / Standard Extension is distributed  *      under the T-License for T-Kernel / Standard Extension. *---------------------------------------------------------------------- * *    Version:   1.00.00 *    Released by T-Engine Forum(http://www.t-engine.org) at 2006/8/11. * *---------------------------------------------------------------------- *//* *	euctotc.c (libtcstr) * *	W	euctotc(TC *tc, const UB *euc) * *	Convert an EUC character in euc area into a TC character and store it in tc. *	Return the number of converted bytes (1 or 2) as a function value. *	If tc == NULL, do not store the conversion result, but return a correct function value. *	If the character cannot be converted, return the function value "-1"; if euc is an empty string, return the function value "0". */#include <basic.h>#include <tstring.h>#define TSD_ETC_VAL_0XA0	0xa0#define TSD_ETC_VAL_0XE0	0xe0#define TSD_ETC_MSK_0X7F	0x7fU#define TSD_ETC_MSK_0XFF	0xffU#define TSD_ETC_MSK_0X7F7F	0x7f7fU#define TSD_ETC_SFT_8		8U#define TSD_ETC_RTN_2		2#define TSD_ETC_RTN_M1		(-1)#define TSD_ETC_VAL_0X8E	0x8e#define TSD_ETC_MSK_0X80	0x80UIMPORT	const TC	_hzkana[];EXPORT	W	euctotc( TC *tc, const UB *euc ){	W	ec;	ec = (W)*(euc++);	if (ec == TSD_ETC_VAL_0X8E) {		ec = (W)*euc;		if ((ec < TSD_ETC_VAL_0XA0 )||( ec >= TSD_ETC_VAL_0XE0)) {			return TSD_ETC_RTN_M1;		}		/* Single-width katakana */		if (tc != 0) {			*tc = _hzkana[ec - TSD_ETC_VAL_0XA0];		}		return TSD_ETC_RTN_2;	}	if (((UW)ec & TSD_ETC_MSK_0X80) != 0) {		if ((*euc & TSD_ETC_MSK_0X80) == 0) {			return TSD_ETC_RTN_M1;		}		/* Double-width */		if (tc != 0) {			*tc = (TC)((((UW)ec << TSD_ETC_SFT_8) | (UH)(*euc & TSD_ETC_MSK_0XFF)) & TSD_ETC_MSK_0X7F7F);		}		return TSD_ETC_RTN_2;	}	if (ec == 0) {		return 0;	}	if (tc != 0) {		*tc = _asctotc[(UW)ec & TSD_ETC_MSK_0X7F];	}	return 1;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -