Example #1
0
 public static PropertyItem[] LoadProperties(UnicodeVersion version)
 => (
     from line in GetUcdDefinition(version).Result
     let commentRemoved = line.Split('#').FirstOrDefault()
                              where !string.IsNullOrWhiteSpace(commentRemoved)
                          let x = commentRemoved.Split(';')
                                  let range = x[0]
                                              let nums = range.Split('.')
                                                         let min = nums[0]
                                                                   let max = nums.Length == 3 ? nums[2] : nums[0]
                                                                             let property = x[1]
                                                                                            select new PropertyItem(int.Parse(min, HexNumber), int.Parse(max, HexNumber), Enum.Parse <GraphemeBreakProperty>(property))
     ).ToArray();
Example #2
0
        static void Generate(UnicodeVersion version)
        {
            var items = Loader.LoadProperties(version);

            const string pathFormat = "../GraphemeSplitter/Character.{0}.cs";

            using (var w = new StreamWriter(string.Format(pathFormat, "GetGraphemeBreakProperty" + version)))
            {
                w.WriteLine("#if UnicodeVersion" + version);
                GenerateBinaryIfCode(items, "Character", "GetGraphemeBreakProperty", w);
                w.WriteLine("#endif");
            }
        }
Example #3
0
        static async Task <string[]> GetUcdDefinition(UnicodeVersion version)
        {
            var path = version + ".txt";

            if (File.Exists(path))
            {
                return(await File.ReadAllLinesAsync(path));
            }

            var url = Urls.TryGetValue(version, out var x) ? x : throw new IndexOutOfRangeException();

            var c   = new HttpClient();
            var res = await c.GetAsync(url);

            var text = await res.Content.ReadAsStringAsync();

            await File.WriteAllTextAsync(path, text);

            return(text.Split('\n'));
        }
 public static UnicodeBlockInfo Find(CodePoint c, UnicodeVersion version = UnicodeVersion.V3_2)
 {
     if (c == CodePoint.Null)
     {
         throw new ArgumentOutOfRangeException();
     }
     if (version == UnicodeVersion.V3_2)
     {
         return Find(BlocksV3_2.Value, c);
     }
     throw new ArgumentOutOfRangeException();
 }
 public static CodePointDescription Find(CodePoint c, UnicodeVersion version = UnicodeVersion.V3_2)
 {
     if (c.IsNull)
     {
         throw new ArgumentNullException();
     }
     if (version == UnicodeVersion.V3_2)
     {
         CodePointDescription descr;
         DescrFromCodePointV3_2.Value.TryGetValue(c, out descr);
         return descr;
     }
     throw new ArgumentOutOfRangeException();
 }