gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-05 07:58:41 27 4
gpt4 key购买 nike

调试时,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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com