예제 #1
0
파일: Escape.cs 프로젝트: noorsyyad/nHapi
            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}\\");
            }
예제 #2
0
 private void TryAddEscapeSequence(char key, string value)
 {
     if (!EscapeSequences.ContainsKey(key))
     {
         EscapeSequences.Add(key, value);
     }
 }