zoukankan      html  css  js  c++  java
  • 什么是Unicode letter

    起因:从一段代码说起

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace Test
    {
        class Program
        {
            static void Main(string[] args)
            {
                string temp = "1610MM001A衫片";
                foreach (Char item in temp)
                {
                    if (char.IsLetter(item))
                    {
                        Console.WriteLine(item);
                    }
                }
                Console.ReadKey();
                
            }
        }
    }

    这段代码的输出  

    原本以为是“MMA”,为什么汉子“衫片”也是?

    F12,看一下

    那么什么是Unicode(参见http://www.cnblogs.com/John-Marnoon/p/5825906.html),

    那么,Unicode Letter都包括什么呢?

    首先,查一下微软的Char.IsLetter 方法 (String, Int32)

    https://msdn.microsoft.com/zh-cn/library/zff1at55(v=vs.110).aspx

    其次,看一下IsLetter的源代码

     

    进一步看看CheckLetter方法

    大写字母、小写字母、标题字母(首字母大写)、修饰语字母、其他字母。

    因为各个国家的语言都不一样,例如有的语言是带声调的。所以仅从个人理解以及涉及到的应用范围,这个unicode letter应该是所有汉字+英文字母,数字和符号大多不包括在内。

    但是也有例外。。。。

     例如下面就会让你蒙圈了。。。 哈哈哈

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace Test
    {
        class Program
        {
            static void Main(string[] args)
            {
                bool a1 = char.IsLetter('!');
                bool a2 = char.IsLetter('ǃ');
                bool b1 = char.IsLetter('|');
                bool b2 = char.IsLetter('ǀ');
    
                Console.WriteLine(a1);
                Console.WriteLine(a2);
                Console.WriteLine(b1);
                Console.WriteLine(b2);
              Console.ReadKey();
            }
        }
    }

    如有错误,还请不吝指教。

    附录

    这五类具体包括什么,请查询 http://www.fileformat.info/info/unicode/category/index.htm

  • 相关阅读:
    Windows Phone开发(40):漫谈关键帧动画之中篇 转:http://blog.csdn.net/tcjiaan/article/details/7559978
    Windows Phone开发(43):推送通知第一集——Toast推送 转:http://blog.csdn.net/tcjiaan/article/details/7617664
    xslt运算符
    简单实现Ajax
    继承与多态
    servlet基础知识
    用telnet 测试Http协议
    http协议基础
    类的初始化
    多态
  • 原文地址:https://www.cnblogs.com/John-Marnoon/p/6046775.html
Copyright © 2011-2022 走看看