如何判断中英文

 

        bool isChineseChar(char ch)

        {

            int i = ch & 0x80;            

    return ( i > 0);        

  }

        private void button1_Click(object sender, EventArgs e)

        {

            string str = textBox1.Text;

            byte[] b = Encoding.Default.GetBytes(str);

            string str1 = Convert.ToString(b[0], 16);

            int len = b.Length;

            if (isChineseChar((char)b[0]))

            {

                MessageBox.Show("中文");

            }

            else

            {

                MessageBox.Show("英文");

            }

        }

posted @ 2014-03-12 15:58  萧萧  阅读(156)  评论(0)    收藏  举报