Esempio n. 1
0
        public void WriteCodes2()
        {
            EnsureCodeMapBuild();
            //int tot = 0;
            //foreach ( var pair in _codeMap ) {
            //    if ( pair.Key != pair.Value ) {
            //        Debug.WriteLine( $"{pair.Key:X4}:{pair.Value:X4}" );
            //        tot++;
            //    }
            //}

            var map = new InterleaveMap();

            for (int i = 0; i <= ushort.MaxValue; i++)
            {
                if (_codeMap.TryGetValue((ushort)i, out ushort value))
                {
                    map.Add((char)i, i ^ value);
                }
            }

            using (var w = File.Create(@"F:\Dev\GitHub\ecl.Unicode\src\GenIOCMap\Scanner2.bin"))
                using (var b = new BinaryWriter(w)) {
                    map.Save(b);
                    WriteComposites(b);
                }
        }
Esempio n. 2
0
        public void BuildToUpperMap(bool text = false)
        {
            var map = new InterleaveMap();

            foreach (KeyValuePair <int, int> pair in _iocMap)
            {
                if (!_iocMap.TryGetValue(pair.Value, out int key) ||
                    key != pair.Key)
                {
                    Console.WriteLine("{0:X6} != {1:X6}", key, pair.Key);
                }
                else
                {
                    UnicodeEntry left = _loader[pair.Key];
                    //var right = _loader[ pair.Value ];
                    if (left.Uppercase != 0)
                    {
                        if (left.Uppercase != pair.Value)
                        {
                            Console.WriteLine("{0:X6} != {1:X6}", key, pair.Key);
                        }
                        else
                        {
                            int diff = pair.Value ^ pair.Key;
                            map.Add((char)pair.Key, diff);
                        }
                    }
                    else if (left.LowerCase != pair.Value)
                    {
                        Console.WriteLine("{0:X6} != {1:X6}", key, pair.Key);
                    }
                }
            }

            if (text)
            {
                using (var w = File.CreateText(@"../../bin/OrdinalIgnoreCaseMap.cs")) {
                    map.Write(w);
                }
            }
            else
            {
                using (var w = File.Create(@"../../bin/OrdinalIgnoreCaseMap.bin"))
                    using (var b = new BinaryWriter(w)) {
                        map.Save(b);
                    }
            }
        }