Ejemplo n.º 1
0
        /// <summary>
        /// Reads DerivedName.txt and parses each entry in that file.
        /// </summary>
        private static Dictionary <int, string> ProcessDerivedNameFile()
        {
            using Stream stream       = Resources.OpenResource(Resources.DerivedName);
            using StreamReader reader = new StreamReader(stream);

            Dictionary <int, string> dict = new Dictionary <int, string>();

            string thisLine;

            while ((thisLine = reader.ReadLine()) != null)
            {
                if (PropsFileEntry.TryParseLine(thisLine, out PropsFileEntry value))
                {
                    if (value.IsSingleCodePoint)
                    {
                        // Single code point of format "XXXX ; <Name>" (name shouldn't end with '*')

                        Assert.False(value.PropName.EndsWith('*'));
                        dict.Add(value.FirstCodePoint, value.PropName);
                    }
                    else
                    {
                        // Range of format "XXXX..YYYY ; <Name>-*"

                        Assert.True(value.PropName.EndsWith('*'));

                        string baseName = value.PropName[..^ 1];
Ejemplo n.º 2
0
        public static bool TryParseLine(string line, out PropsFileEntry value)
        {
            Match match = _regex.Match(line);

            if (!match.Success)
            {
                value = default; // no match
                return(false);
            }

            uint firstCodePoint = uint.Parse(match.Groups["firstCodePoint"].Value, NumberStyles.HexNumber, CultureInfo.InvariantCulture);
            uint lastCodePoint  = firstCodePoint; // assume no "..YYYY" segment for now

            if (match.Groups["lastCodePoint"].Success)
            {
                lastCodePoint = uint.Parse(match.Groups["lastCodePoint"].Value, NumberStyles.HexNumber, CultureInfo.InvariantCulture);
            }

            value = new PropsFileEntry(firstCodePoint, lastCodePoint, match.Groups["propName"].Value);
            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Reads DerivedBidiClass.txt and parses each entry in that file.
        /// </summary>
        private static Dictionary <int, BidiClass> ProcessDerivedBidiClassFile()
        {
            using Stream stream       = Resources.OpenResource(Resources.DerivedBidiClass);
            using StreamReader reader = new StreamReader(stream);

            Dictionary <int, BidiClass> dict = new Dictionary <int, BidiClass>();

            string thisLine;

            while ((thisLine = reader.ReadLine()) != null)
            {
                if (PropsFileEntry.TryParseLine(thisLine, out PropsFileEntry value))
                {
                    BidiClass bidiClass = BidiClassMap[value.PropName];

                    for (int i = value.FirstCodePoint; i <= value.LastCodePoint /* inclusive */; i++)
                    {
                        dict.Add(i, bidiClass);
                    }
                }
            }

            return(dict);
        }