Is Xml Name Start Char - CSharp System.Xml

CSharp examples for System.Xml:XML String

Description

Is Xml Name Start Char

Demo Code

// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.

public class Main{
        public static bool IsXmlNameStartChar(char chr)
        {/*from   w  w w . j a v a2 s  .c o m*/
            // [4] NameStartChar    ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | 
            //                          [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | 
            //                          [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
            // http://www.w3.org/TR/REC-xml/#NT-Name

            return Char.IsLetter(chr) ||
                   chr == ':' ||
                   chr == '_' ||
                   IsInRange(chr, 0xC0, 0xD6) ||
                   IsInRange(chr, 0xD8, 0xF6) ||
                   IsInRange(chr, 0xF8, 0x2FF) ||
                   IsInRange(chr, 0x370, 0x37D) ||
                   IsInRange(chr, 0x37F, 0x1FFF) ||
                   IsInRange(chr, 0x200C, 0x200D) ||
                   IsInRange(chr, 0x2070, 0x218F) ||
                   IsInRange(chr, 0x2C00, 0x2FEF) ||
                   IsInRange(chr, 0x3001, 0xD7FF) ||
                   IsInRange(chr, 0xF900, 0xFDCF) ||
                   IsInRange(chr, 0xFDF0, 0xFFFD) ||
                   IsInRange(chr, 0x10000, 0xEFFFF);
        }
}

Related Tutorials