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

  • 相关阅读:
    csu 1547(01背包)
    csu 1592(区间DP)
    Funny Car Racing(最短路变形)
    csu 1329 一行盒子(链表操作)
    poj 2828(线段树单点更新)
    软件开发文档模板 (学习)
    C 语言高效编程与代码优化
    【整理】uclibc,eglibc,glibc之间的区别和联系
    查找openssl内存泄漏(代码)
    openssl内存分配,查看内存泄露
  • 原文地址:https://www.cnblogs.com/John-Marnoon/p/6046775.html
Copyright © 2011-2022 走看看