Exemplo n.º 1
0
        static UniHanData()
        {
            var settings = Properties.Settings.Default;

            Sources = new MultiDict<int, string>();
            Mappings = new MultiDict<int, string>();
            Variants = new MultiDict<int, int>();

            var path = Path.Combine(Path.GetDirectoryName(typeof(UniHanData).Assembly.Location), settings.UnicodeZipFilename);
            using (var zip = ZipFile.OpenRead(path))
            {
                using (var rd = new FieldReader(zip.GetEntry(settings.Unihan_IRGSources).Open(), '\t'))
                {
                    string[] fields;
                    while ((fields = rd.Read()) != null)
                    {
                        if (fields[1].StartsWith("kIRG_") && fields[1].EndsWith("Source"))
                        {
                            var code = int.Parse(fields[0].Substring(2), NumberStyles.HexNumber);
                            Sources.Add(code, fields[2]);
                        }
                        else if (fields[1].EndsWith("Variant"))
                        {
                            var code = int.Parse(fields[0].Substring(2), NumberStyles.HexNumber);
                            var vant = int.Parse(fields[2].Substring(2), NumberStyles.HexNumber);
                            Variants.Add(code, vant);
                        }
                    }
                }

                using (var rd = new FieldReader(zip.GetEntry(settings.Unihon_OtherMappings).Open(), '\t'))
                {
                    string[] fields;
                    while ((fields = rd.Read()) != null)
                    {
                        var code = int.Parse(fields[0].Substring(2), NumberStyles.HexNumber);
                        var mapping = fields[1].Substring(1) + "-" + fields[2].Replace(',', '-').Replace(':','-');
                        Mappings.Add(code, mapping);
                    }
                }

                using (var rd = new FieldReader(zip.GetEntry(settings.Unihan_Variants).Open(), '\t'))
                {
                    string[] fields;
                    while ((fields = rd.Read()) != null)
                    {
                        var code = int.Parse(fields[0].Substring(2), NumberStyles.HexNumber);
                        foreach (var v in fields[2].Split('\t', ' ', '<').Where(s => s.StartsWith("U+")))
                        {
                            var vant = int.Parse(v.Substring(2), NumberStyles.HexNumber);
                            Variants.Add(code, vant);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        static OtherData()
        {
            var settings = Properties.Settings.Default;

            var classes = new MultiDict<int, string>();
            var reuser = new ObjectReuser<string>();

            var path = Path.Combine(Path.GetDirectoryName(typeof(OtherData).Assembly.Location), settings.UnicodeZipFilename);
            using (var zip = ZipFile.OpenRead(path))
            {
                using (var rd = new FieldReader(zip.GetEntry(settings.OtherAttribution).Open(), ';'))
                {
                    string[] fields;
                    while ((fields = rd.Read()) != null)
                    {
                        classes.Add(int.Parse(fields[0], System.Globalization.NumberStyles.HexNumber), reuser.Get(fields[1].Trim()));
                    }
                }
            }

            Classes = classes;
        }
Exemplo n.º 3
0
        static OtherData()
        {
            var settings = Properties.Settings.Default;

            var classes = new MultiDict <int, string>();
            var reuser  = new ObjectReuser <string>();

            var path = Path.Combine(Path.GetDirectoryName(typeof(OtherData).Assembly.Location), settings.UnicodeZipFilename);

            using (var zip = ZipFile.OpenRead(path))
            {
                using (var rd = new FieldReader(zip.GetEntry(settings.OtherAttribution).Open(), ';'))
                {
                    string[] fields;
                    while ((fields = rd.Read()) != null)
                    {
                        classes.Add(int.Parse(fields[0], System.Globalization.NumberStyles.HexNumber), reuser.Get(fields[1].Trim()));
                    }
                }
            }

            Classes = classes;
        }