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); } }
public void WriteScriptMap() { _loader.EnsureDataLoaded(); _loader.EnsureScriptsLoaded(); EnsureCodeMapBuild(); var map = new Dictionary <int, ScriptSystem>(); foreach (var entry in _loader.GetCodePoints(0, ushort.MaxValue)) { if (entry.Script != 0) { ScriptSystem sys = GetScriptSystem(entry.Script); map.Add(entry.CodeValue, sys); } } #if true1 using (var w = File.CreateText(@"f:\_tests\Del\ScriptMap.txt")) { for (int i = 0; i <= ushort.MaxValue; i++) { if (map.TryGetValue(i, out ScriptSystem value)) { } string text = $"{i:X4} "; if (_loader.TryGetEntry(i, out UnicodeEntry entry)) { if (IsPrintable(entry.Category)) { text += entry + " "; } if (entry.Script != 0) { text += "[" + entry.Script + "] "; } text += entry.Name + " "; } w.WriteLine(text + value); } } #else InterleaveMap imap = new InterleaveMap(); for (int i = 0; i <= ushort.MaxValue; i++) { if (map.TryGetValue(i, out ScriptSystem value)) { imap.Add((char)i, (int)value); } } using (var w = File.Create(@"f:\_tests\Del\ScriptMap.bin")) using (var b = new BinaryWriter(w)){ imap.SaveByte(b); } #endif }
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); } } }
public void WriteCodes3() { EnsureCodeMapBuild(); var map = new InterleaveMap(); for (int i = 0; i <= ushort.MaxValue; i++) { if (_codeMap.TryGetValue((ushort)i, out ushort value) && value >= 32) { map.AddSet((char)i, i ^ value); } else { map.Add((char)i, 0); } } using (var w = File.Create(@"F:\Dev\GitHub\ecl.Unicode\src\GenIOCMap\Scanner2.bin")) using (var b = new BinaryWriter(w)) { map.SaveMasked(b); WriteComposites(b); } }
public void WriteBreakMap() { EnumRange <WordBreak>[] breaks = _loader.LoadWordBreak(); var map = new Dictionary <int, byte>(); foreach (var range in breaks) { //switch ( range.Value ) { //case WordBreak.MidLetter: // continue; //} for (int i = range.Begin; i <= range.End; i++) { if (!map.ContainsKey(i)) { map[i] = (byte)range.Value; } else { Debug.WriteLine("DF"); } } } map.Add(160, (byte)MoreWord.Connector); // Non Breaking space map.Add('\t', (byte)WordBreak.WSegSpace); // Tab foreach (var entry in _loader.GetCodePoints(0, ushort.MaxValue)) { if (!map.ContainsKey(entry.CodeValue)) { switch (entry.Category) { case UnicodeCharacterType.OtherPrivateUse: map.Add(entry.CodeValue, (byte)MoreWord.Private); break; case UnicodeCharacterType.OtherSurrogate: map.Add(entry.CodeValue, (byte)MoreWord.Surrogate); break; case UnicodeCharacterType.OtherControl: map.Add(entry.CodeValue, (byte)MoreWord.Control); continue; case UnicodeCharacterType.LetterUppercase: case UnicodeCharacterType.LetterLowercase: case UnicodeCharacterType.LetterTitlecase: map.Add(entry.CodeValue, 52); break; case UnicodeCharacterType.LetterOther: map.Add(entry.CodeValue, (byte)MoreWord.Ideograph); break; case UnicodeCharacterType.NumberOther: case UnicodeCharacterType.LetterModifier: map.Add(entry.CodeValue, (byte)MoreWord.Symbol); break; case UnicodeCharacterType.NumberDecimalDigit: case UnicodeCharacterType.MarkEnclosing: map.Add(entry.CodeValue, (byte)MoreWord.Symbol); break; case UnicodeCharacterType.NumberLetter: case UnicodeCharacterType.SymbolMath: case UnicodeCharacterType.SymbolCurrency: case UnicodeCharacterType.SymbolModifier: case UnicodeCharacterType.SymbolOther: map.Add(entry.CodeValue, (byte)MoreWord.Symbol); break; case UnicodeCharacterType.PunctuationConnector: map.Add(entry.CodeValue, (byte)MoreWord.Punctuation); break; case UnicodeCharacterType.PunctuationDash: case UnicodeCharacterType.PunctuationOpen: case UnicodeCharacterType.PunctuationClose: case UnicodeCharacterType.PunctuationInitialQuote: case UnicodeCharacterType.PunctuationFinalQuote: case UnicodeCharacterType.PunctuationOther: map.Add(entry.CodeValue, (byte)MoreWord.Punctuation); break; case UnicodeCharacterType.OtherFormat: case UnicodeCharacterType.SeparatorSpace: map.Add(entry.CodeValue, (byte)MoreWord.WhiteSpace); break; case UnicodeCharacterType.MarkSpacingCombining: case UnicodeCharacterType.SeparatorLine: case UnicodeCharacterType.SeparatorParagraph: map.Add(entry.CodeValue, (byte)MoreWord.LineSeparator); break; default: map.Add(entry.CodeValue, 60); break; } } } #if true1 using (var w = File.CreateText(@"f:\_tests\Del\WordBreak.txt")) { for (int i = 0; i <= ushort.MaxValue; i++) { string text = $"{i:X4} "; if (_loader.TryGetEntry(i, out UnicodeEntry entry)) { if (IsPrintable(entry.Category)) { text += entry + " "; } text += entry.Name + " "; } map.TryGetValue(i, out var value); w.WriteLine(text + value); } } #else InterleaveMap imap = new InterleaveMap(); for (int i = 0; i <= ushort.MaxValue; i++) { if (map.TryGetValue(i, out byte value)) { imap.Add((char)i, value); } } using (var w = File.Create(@"f:\_tests\Del\WordBreak2.bin")) using (var b = new BinaryWriter(w)){ imap.SaveByte(b); } #endif }