如何知道一个字符串是中文还是外文 逐个比较ascii码。汉字的字节码>125? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 (buff[i] & 0x80) != 0就可以了 main(){ int j; FILE *fp; char filename[50],str; printf("file name!\n"); scanf("%s",&filename); if((fp=fopen(filename,"rb"))==NULL) { printf("Error opening source file!\n"); return -1;} j=0;do { str=fgetc(fp); if (!((str>0)&(str<128))) j=1;} while(!feof(fp));printf("j=%d",j);return 0;}若j=1则说明其中有中文,否则则没有 汉字的高位码>0xA0 while (TempChar = * strin ++) { if (TempChar == 0x0A) /* new line */ { if (LastChar != 0) { *p++ = LastChar; LastChar = 0; } *p ++ = TempChar; } else if (LastChar != 0) /* a chinese char second byte? */ { OutChar = 0; index = (LastChar - 0xA1) * 0x5E + (TempChar - 0xA1); /* TempChar: second byte, LastChar: first byte */ if (index >= 0 && index < GBToBig5TblSize) OutChar = GBToBig5Tbl[index]; if (OutChar != 0) { * p ++ = HIBYTE(OutChar); * p ++ = LOBYTE(OutChar); } else { * p ++ = HIBYTE(BIGbox); * p ++ = LOBYTE(BIGbox); } LastChar = 0; } else if (TempChar > 0xA0) { LastChar = TempChar; } else { * p ++ = TempChar; } /* a new single char, is a chinese first byte ? */ } 求助,关于拷贝构造函数的问题 高分求助-------线程同步问题 求解V-G脚本的实现方法 一个非com环境下的生命周期问题 急,高分求图像去噪音的算法? 用ITaskbarList接口显示或隐藏窗口在任务栏上的按钮 如何把windows98的IE浏览器地址栏的历史站点记录去掉啊急 请问如何实现远程进程分析代码? win7 传输文件的问题 求助TOOLINFO 高级用法 那位大哥知道函数钩子的资料,我的编译不过去 请问SYSTEM(“CD DIR”)函数中STR可不可以为字符串变量,可以的话请问代码如何写
{
int j;
FILE *fp;
char filename[50],str;
printf("file name!\n");
scanf("%s",&filename);
if((fp=fopen(filename,"rb"))==NULL) {
printf("Error opening source file!\n");
return -1;
}
j=0;
do {
str=fgetc(fp);
if (!((str>0)&(str<128)))
j=1;} while(!feof(fp));
printf("j=%d",j);
return 0;
}
若j=1则说明其中有中文,否则则没有
while (TempChar = * strin ++)
{
if (TempChar == 0x0A) /* new line */
{
if (LastChar != 0)
{
*p++ = LastChar;
LastChar = 0;
} *p ++ = TempChar;
}
else if (LastChar != 0) /* a chinese char second byte? */
{
OutChar = 0;
index = (LastChar - 0xA1) * 0x5E + (TempChar - 0xA1);
/* TempChar: second byte, LastChar: first byte */
if (index >= 0 && index < GBToBig5TblSize)
OutChar = GBToBig5Tbl[index]; if (OutChar != 0)
{
* p ++ = HIBYTE(OutChar);
* p ++ = LOBYTE(OutChar);
}
else
{
* p ++ = HIBYTE(BIGbox);
* p ++ = LOBYTE(BIGbox);
}
LastChar = 0;
}
else if (TempChar > 0xA0)
{
LastChar = TempChar;
}
else
{
* p ++ = TempChar;
}
/* a new single char, is a chinese first byte ? */
}