internal static string FormatLiteral(char c, ObjectDisplayOptions options)
        {
            StringBuilder builder = new StringBuilder();

            if (options.IncludesOption(ObjectDisplayOptions.IncludeCodePoints))
            {
                builder.Append(options.IncludesOption(ObjectDisplayOptions.UseHexadecimalNumbers) ? "0x" + ((int)c).ToString("x4") : ((int)c).ToString());
                builder.Append(" ");
            }
            bool flag1 = options.IncludesOption(ObjectDisplayOptions.UseQuotes);
            bool flag2 = options.IncludesOption(ObjectDisplayOptions.EscapeNonPrintableCharacters);

            if (flag1)
            {
                builder.Append('\'');
            }
            string replaceWith;

            if (flag2 && ObjectDisplay.TryReplaceChar(c, out replaceWith))
            {
                builder.Append(replaceWith);
            }
            else if (flag1 && c == '\'')
            {
                builder.Append('\\');
                builder.Append('\'');
            }
            else
            {
                builder.Append(c);
            }
            if (flag1)
            {
                builder.Append('\'');
            }
            return(builder.ToString());
        }
        public static string FormatLiteral(string value, ObjectDisplayOptions options)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }
            StringBuilder builder = new StringBuilder();
            bool          flag1   = options.IncludesOption(ObjectDisplayOptions.UseQuotes);
            bool          flag2   = options.IncludesOption(ObjectDisplayOptions.EscapeNonPrintableCharacters);
            bool          flag3   = flag1 && !flag2 && ObjectDisplay.ContainsNewLine(value);

            if (flag1)
            {
                if (flag3)
                {
                    builder.Append('@');
                }
                builder.Append('"');
            }
            for (int index = 0; index < value.Length; ++index)
            {
                char ch = value[index];
                if (flag2 && CharUnicodeInfo.GetUnicodeCategory(ch) == UnicodeCategory.Surrogate)
                {
                    UnicodeCategory unicodeCategory = CharUnicodeInfo.GetUnicodeCategory(value, index);
                    if (unicodeCategory == UnicodeCategory.Surrogate)
                    {
                        builder.Append("\\u" + ((int)ch).ToString("x4"));
                    }
                    else if (ObjectDisplay.NeedsEscaping(unicodeCategory))
                    {
                        int utf32 = char.ConvertToUtf32(value, index);
                        builder.Append("\\U" + utf32.ToString("x8"));
                        ++index;
                    }
                    else
                    {
                        builder.Append(ch);
                        builder.Append(value[++index]);
                    }
                }
                else
                {
                    string replaceWith;
                    if (flag2 && ObjectDisplay.TryReplaceChar(ch, out replaceWith))
                    {
                        builder.Append(replaceWith);
                    }
                    else if (flag1 && ch == '"')
                    {
                        if (flag3)
                        {
                            builder.Append('"');
                            builder.Append('"');
                        }
                        else
                        {
                            builder.Append('\\');
                            builder.Append('"');
                        }
                    }
                    else
                    {
                        builder.Append(ch);
                    }
                }
            }
            if (flag1)
            {
                builder.Append('"');
            }
            return(builder.ToString());
        }