c++ - 在 Visual Studio 2008 中显示 CR/LF 的 Visual C++ 调试窗口

标签 c++ visual-studio-2008 debugging newline

一段时间以来,当我调试 Visual C++ 应用程序并在 Local、Auto 或 Watch 调试窗口中查看任何 CString 或 char*(或任何其他基于 ascii 字符的类型)变量时,我的变量中的 CR/LF 字符根本不显示。

换句话说,如果我在代码中将字符串变量设置为“This is a line\r\nThis is another line”,调试窗口将显示“This is a lineThis is another line”。我希望它显示的是“这是一行□□这是另一行”,这样我就可以看到该文本中的两个额外字符。

这导致我在尝试调试字符串解析代码时犯了一些错误。请注意,文本可视化工具正确地将文本分成单独的行,但如果不需要,我不想使用文本可视化工具。此外,我的一些同事能够以正确的方式看到 CR/LF 字符,但我们无法确定为什么它们没有显示给我。

非常感谢。

最佳答案

根据 this old link,这似乎是某种难以重现的错误(我也没有在 2k8 中看到它们) :

If we wanted to do this properly we'd need to issue the proper escape sequences for these characters. eg show "\r\n" in the string. The behavior of stripping special characters historical and will be fixed in a future release. If you are viewing text with newlines in it you can either view the string as a character array: type "str,100" to view a string of length 100 as an array. Or you can click on the magnifying glass glyph and view the string in a multiline edit control.

一个月后:

We cannot reproduce this problem on neither VS2003 nor VS2005. This looks like a machine-specific problem.

因此,如果您的同事真的看到了它,那么我们的设置中一定发生了一些奇怪的事情。

关于c++ - 在 Visual Studio 2008 中显示 CR/LF 的 Visual C++ 调试窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/835038/

相关文章:

c++ - 可以将多维 std::array 视为连续的数据 block 吗?

c++ - 更新 glibc 后 std::tan() 非常慢

iphone - 在数组中存储 cvMat 对象 - OpenCV - iPhone

vb.net - 如何保存在VB中所做的设置?

c++使用visual studio编译错误

PHP "Notice: Undefined index"是无害的还是真正的错误?

c++ - 二元 boolean 运算符是否具有结合性?

c# - 如何从 SVN 存储库获取分支的最高修订号?

angular - 安装Sentry(Raven)后无法获取控制台日志

c - Valgrind 错误根据输入而变化。如何解决?