Reputation: 84550
If I evaluate something in Immediate that produces a long and complex string, the debugger encodes everything in C string escapes, so I end up with a mess of \n
, \t
, and so on throughout my text which I then have to fix by hand. (Which is particularly annoying in the case of \n
, as most text editors can't do multiline search-and-replace!)
Is there any way to get the debugger to give me the raw, un-munged, multi-line string value?
Upvotes: 6
Views: 5979
Reputation: 653
Set a format specifier at the end of the expression in the immediate window.
Problem:
? "test string with escape chars \r\nThis is on the next line"
"test string with escape chars \r\nThis is on the next line"
Add the , nq format specifier to the end:
? "test string with escape chars \r\nThis is on the next line", nq
test string with escape chars
This is on the next line
This works exactly the same with a real variable:
? testvariable, nq
test string with escape chars
This is on the next line
(I tried the answer from Konstantine Kozachuck using a format specifier on the Print statement and it did not work the same way the ? statement did, but it did help me figure out want I wanted.)
Upvotes: 3
Reputation: 2703
You can use C# Interactive Window (Views > Other Windows > C# Interactive).
Usage:
Type command:
Console.Write("r1bqkb1r/pp3ppp/2p5/3pP3/P2Q1P2/2N1B3/1PP3PP/R4RK1 w - - 1 2\nr1bqkb1r/pp3ppp/2p5/3pP3/P2Q1P2/2N1B3/1PP3PP/R4RK1 w - - 1 2")
Then I'll get:
r1bqkb1r/pp3ppp/2p5/3pP3/P2Q1P2/2N1B3/1PP3PP/R4RK1 w - - 1 2
r1bqkb1r/pp3ppp/2p5/3pP3/P2Q1P2/2N1B3/1PP3PP/R4RK1 w - - 1 2
C# Interactive Window is independent from the project so it will work on all projects of all language (C#, C++,...)
Here is the demo image:
Upvotes: 1
Reputation: 379
Print variableName,sb
.
Example (Immediate window):
>"raw\nmultiline\tstring",sb
raw
multiline string
Documentation: https://learn.microsoft.com/en-us/visualstudio/debugger/format-specifiers-in-cpp?view=vs-2019
Upvotes: 0
Reputation: 3766
We could check the string value with Text Visualizer in Watch window, which will show the string value without any \n and \t content.
Please add a breakpoint in the string variable in your code and start debugging your code. When the breakpoint hit, you could right-click the variable and choose "Add Watch" Then press F11 to go to next line of code. Now you could view the string value from Watch window by click the "Text Visualizer" icon. It will not show the \n and \t.
Upvotes: 4