protected static string ReplaceInvalidChars()

in src/TestFramework/Core/Logging/LogSink.cs [197:220]


        protected static string ReplaceInvalidChars(string message)
        {
            if (message == null) return null;
            StringBuilder sbOutput = new StringBuilder();
            char ch;
            for (int i = 0; i < message.Length; i++)
            {
                ch = message[i];

                //Refer to REC-xml-20040204 section 2.2
                //Available at http://www.w3.org/TR/2004/REC-xml-20040204/#charsets
                if ((ch >= 0x0020 && ch <= 0xD7FF) ||
                (ch >= 0xE000 && ch <= 0xFFFD) ||
                ch == 0x0009 || ch == 0x000A || ch == 0x000D)
                {
                    sbOutput.Append(ch);
                }
                else
                {
                    sbOutput.Append("\\u"+((UInt16)ch).ToString("X4"));
                }
            }
            return sbOutput.ToString();
        }