判斷一個(gè)文本是否還有漢字
if od -c urfile | grep '[1-9][0-9][0-9]';then
echo "chinese"
fi
file urfile
UTF-8 --- chinese
[root@localhost test]# cat chinese.c
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int
first (unsigned char ch)
{
if (ch >= 0xb0 && ch <= 0xf7)
return 1;
else
return 0;
}
int
second (unsigned char ch)
{
if (ch >= 0xa1 && ch <= 0xfe)
return 1;
else
return 0;
}
int
check (const char *p)
{
int i = 0;
for (i = 0; i < strlen (p)-1; i++)
if (first (p[i]) && second (p[i + 1]))
return 1;
return 0;
}
int
main ()
{
const char *str = "aasdasdas";
check (str) ? printf("there has character!\n"):printf("there has none character!\n");
return 0;
}
本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請
點(diǎn)擊舉報。