private void BuildLookups(EncodingCharacters encoding) { SpecialCharacters[0] = encoding.FieldSeparator; SpecialCharacters[1] = encoding.ComponentSeparator; SpecialCharacters[2] = encoding.SubcomponentSeparator; SpecialCharacters[3] = encoding.RepetitionSeparator; SpecialCharacters[4] = encoding.EscapeCharacter; SpecialCharacters[5] = TruncateChar; SpecialCharacters[6] = LineFeed; SpecialCharacters[7] = CarriageReturn; for (var i = 0; i < Codes.Length; i++) { var seq = $"{encoding.EscapeCharacter}{Codes[i]}{encoding.EscapeCharacter}"; EscapeSequences.Add(SpecialCharacters[i], seq); } // Escaping of truncation # is not implemented yet. It may only be escaped if it is the first character that // exceeds the conformance length of the component (ch 2.5.5.2). As of now, this information is not // available at this place. EscapeSequences.Add(TruncateChar, $"{TruncateChar}"); EscapeSequences.Add(LineFeed, $"\\{LineFeedHexadecimal}\\"); EscapeSequences.Add(CarriageReturn, $"\\{CarriageReturnHexadecimal}\\"); }
private void TryAddEscapeSequence(char key, string value) { if (!EscapeSequences.ContainsKey(key)) { EscapeSequences.Add(key, value); } }