This question already has answers here:
Remove or Convert ' to (')
(3 answers)
Closed 7 years ago.
I found a similar question on how to decode ^#39; or simply ' in php, but I have been having trouble finding a way of decoding that value in c#. Thoughts? I have been trying the following in my code...
agenda.MeetingLocation = agenda.MeetingLocation.Replace("'", "''")
However, the value in my form field is John Doe's test. The value I see for agenda.MeetingLocation is:
John Doe's test
(the ^ is a &)
This should work if it's encoded like "& #39;" instead of "^#39;". Are you sure your input uses "^"?
System.Web.HttpUtility.HtmlDecode("John Doe's test.");
Related
This question already has answers here:
How to encode the plus (+) symbol in a URL
(6 answers)
Closed 1 year ago.
I created the custom link on the asp.net core project. And i tried to getting parameters in the link on the controller.
i need to prmtr1 and prmt2 values but '+' char in the prmtr1 return to ' '(space) value. I must get 'j+vNMbBKUGU=' but im getting 'j vNMbBKUGU='
link: blablabla/contract?prmtr1=j+vNMbBKUGU=&prmtr2=BIIOnHXUgGM=
if i change space char to + char, my problem fixed but i think it's not good idea. I hope you can help me. Thanks.
asp.net assumes that the "+" character is an encoded " " and therefore convert it to a space character.
In javascript you can use the function encodeURIComponent(string) to encode your parameters before sending.
You can read more about the function here: https://www.w3docs.com/snippets/javascript/how-to-encode-javascript-url.html#the-encodeuricomponent-function-5
And you can find more information about why this is happening here: https://stackoverflow.com/a/2678602/16154479
This question already has answers here:
Replace "\\" with "\" in a string in C#
(9 answers)
Escape Characters Aren't Working In Debugger (C#)
(2 answers)
How can I add \ symbol to the end of string in C#
(8 answers)
Why does .NET add an additional slash to the already existent slashes in a path?
(4 answers)
Escape sequence with "\" symbol
(4 answers)
Closed 2 years ago.
I'm struggling with escape characters in C#.
I'm saving a varchar field in a SQL Server database with a quote that needs to be escaped. So, an example could be something like that: (\"value\")
When my frontend application consume this value from API I get the value with a single escape character as i have in the DB.
The problem come up when consuming this API from C# code. For some reason this single character (\) is replaced for three of them (\\\).
After debugging the code I found that when I retrieve the data I get this:
debugging the value
When I click to check the value it seems OK:
Value into Text Visualizer
My question is why theese two extra backslashes are added and how can I get rid of them in order to get only one => (\").
Hope anyone can help me :)
Thanks!
You value should be correct. The debugger window escape the “/“, therefore it appears like escape(backslash)escape(quote).
(//)(/“)
This question already has answers here:
How to replace straight quotation mark (")
(3 answers)
Closed 6 years ago.
Some string variables have a " in the data which recks with my php code. I want to take it out in my C# code before the data gets passed to php. I just can't remember the way of doing it, but I tried with this :
line.Replace(#""", "");
This is not correct in Xamarin, what is the good syntax?
I guess this would work.
line.replace("\"","");
use \ to escape it.
line.Replace("\"", "");
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How can I decode html characters in c#?
I have characters incoming from an HTML, for example:
" ' & >
Exists an native function in C# to convert to your equivalents?
Thanks,advanced.
EDIT
I'm writing a console app
I believe HttpUtility.HtmlDecode is what you're looking for.
This question already has answers here:
How can I decode HTML characters in C#?
(10 answers)
Closed 7 years ago.
How to convert the following text into a proper string in C#?
<IconStyle xmlns="http://earth.google.com/kml/2.0"><color>FFFFFFFF</color><scale>1.0</scale><Icon><href>root://icons/palette-5.png</href><x>192</x><y>192</y><w>32</w><h>32</h></Icon></IconStyle><LabelStyle xmlns="http://earth.google.com/kml/2.0"><scale>0</scale></LabelStyle><BalloonStyle xmlns="http://earth.google.com/kml/2.0"><text>$[description]</text><color>FFFFFFFF</color></BalloonStyle>
Forgot to mention the important catch:how to convert the string in a console application in c#?
That is HTML encoded, so:
HttpUtility.HtmlDecode(myHtmlEncodedString);
Reference: http://msdn.microsoft.com/en-us/library/7c5fyk1k.aspx
HttpUtility.HtmlDecode(string)