Stop Visual Studio Debug Putting Slash in String Containing Double Quotes

Stop visual studio debug putting slash in string containing double quotes

This is expected. Because you are under debug mode you are given the dev version of the string.

To get a user friendly version of the string (actual value without slash) you just have to click on the magnify glass icon on the left

Remove double slash from string C#

It seems like you're trying to actually transfer \r and \x1c as control characters instead. Therefore, you should not escape the backslash.

Send the message like "\r\x1c\r" + message or $"\r\x1c\r{message}" (without @).

When you're using "\\r" or @"\r", you're escaping the backslash character and the message will be sent as textual \r. When you check the value at the receiver end, using a debugger or watch-window, it will show up as "\\r".

json replace backslash to double quote

You can use the replace javascript function like this.

str.replace("\\", "\"");

If there are several \ in the string, use loop to replacing all the \.

If you are using CSharp, do like below.

str = str.Replace("\\", "\"");

Please have a try and let me know if it works or not.

ASP.NET / C# : variable with double quote

What you've done is correct. I believe you are inspecting the string value through QuickWatch/Watch window. If so, you will see escape character \ before every double quote inside the string. Just try this and see you actual value.

Console.WriteLine(str1);

If you want to see a proper string (without \), click on the magnify glass icon on the left in QuickWatch pop-up.

replace \\ with \ using Replace()

\ is used as an escape character in strings. Escape characters are used to encode special "non printed" characters inside a string like \n is new line \" is a quote etc. Because \ is the escape character, in order to write a \ we have to escape it and write it as \\ this shows up as a double slash in code and if you view the string in a debugger but both in memory and when it's printed to the screen it appears as 1.

For instance

string s = "The quick \"brown\" fox jumped\nOver the lazy dog. \\\\o_o//";

will print to the screen as

The quick "brown" fox jumped
Over the lazy dog.\\o_o//

Some light reading on escape sequences and you'll be good to go

Verbatim strings, made in C# by @"" will treat everything as literal and don't have escape characters, if you want a newline you have to write the string over 2 lines. The only escape you can do in a verbatim string is " and that's done by ""

string s = @"The quick ""brown"" fox jumped
Over the lazy dog. \\o_o/";

will have the same output as the escaped string above

The quick "brown" fox jumped
Over the lazy dog.\\o_o//

How to turn off double quotes auto-completion in Visual Studio 2019 for C++ editor?

Update October 2019: it is fixed now starting from version 16.3.2. If not, then check your settings carefully.

Short version: This is a bug in Visual Studio, and hopefully will be fixed. You can up-vote it here.

Longer version:
I decided to report this bug to Visual Studio Team, but someone already did that. So if you are affected by this issue, consider up-voting it.

Link to VS bug tracker: Brace completion when member list is up does not put the character in the right position

Note, that while title of above bug may sound like only Code Analysis is affected, VS Team have marked another - more relevant bug as a duplicate to the above bug (C++ automatic quote completion). And it is not possible to vote closed bug, so only option is to vote the first one I mentioned.



Related Topics



Leave a reply



Submit