Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4742759
  • 博文数量: 930
  • 博客积分: 12070
  • 博客等级: 上将
  • 技术积分: 11448
  • 用 户 组: 普通用户
  • 注册时间: 2008-08-15 16:57
文章分类

全部博文(930)

文章存档

2011年(60)

2010年(220)

2009年(371)

2008年(279)

分类:

2009-06-24 20:27:36


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
#include
#include

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;
}


阅读(2483) | 评论(0) | 转发(1) |
0

上一篇:c 二叉树

下一篇:c 桶排序

给主人留下些什么吧!~~