判断是否为汉字


                // 判断字符串长度,包含汉字
                ASCIIEncoding n = new ASCIIEncoding();
                byte[] b = n.GetBytes(CNABCode.Text);

                // l 为字符串之实际长度
                int lenthCNABCode = 0;
                for (int i = 0; i <= b.Length - 1; i++)
                {
                    // 判断是否为汉字或全脚符号
                    if (b[i] == 63)
                    {
                        lenthCNABCode++;
                    }
                    lenthCNABCode++;
                }

posted @ 2017-10-09 18:31  亘古不变  阅读(495)  评论(0编辑  收藏  举报