visual-studio-2010 - Visual Studio : show all special characters in a string

标签 visual-studio-2010 settings special-characters

调试时,Visual Studio 不显示字符串中的某些特殊字符。大多数人都熟悉 notepad++ 显示特殊字符的方式(从另一篇文章复制): enter image description here

更具体一点,我的字符串包含字符代码为 30 的记录分隔符。Notepad++ 将其显示为 [RS]。 Visual Studio 根本不显示它。所以像 hello[RS]stackoverflow[RS]1[RS]2 这样的字符串变成了 hellostackoverflow12。更糟糕的是,如果字符串以“不可见”字符结尾,则无法注意到这一点,因为该字符串看起来仍然合理。我希望能够在 Debug模式下、将鼠标悬停在字符串上时以及在监 window 口中查看所有字符。

最佳答案

使用正则表达式找出字符串中的特殊字符

static void Main(string[] args)
{
    string str = "Th!s $tri^g c@n$ist $pecial ch@rs";
    Match match = Regex.Match(str, "[^a-z0-9]",
            RegexOptions.IgnoreCase);
    while (match.Success)
    {
        string key = match.Value;
        Console.Write(key);
        match = match.NextMatch();
    }
    Console.ReadLine();
}

关于visual-studio-2010 - Visual Studio : show all special characters in a string,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23884922/

相关文章:

android - 如果 maxLines = 1,为什么字符/剪切 TextView 中的文本?

c++ - 我如何在 C++ 中打印这个“█”特殊字符?

php - 删除标点符号、符号、变音符号、特殊字符的最佳方法是什么?

c# - 为什么build action : None ignored for a *.是cs文件?

.net - 设置文件与 app.config

vb6 - 我应该在哪里存储应用程序特定的设置?

.net - 如何查询DOTNET_CLI_TELEMETRY_OPTOUT是否永久设置为TRUE?

c++ - Visual C++ Express : fmin and fmax identifier not found?

c++ - 如何删除#pragma 区域的 GCC 警告?

c# - 限制 Visual Studio 的编辑区域只显示一个函数或方法