Linked Questions

5 votes
1 answer
7k views

Possible Duplicate: Can I convert a C# string value to an escaped string literal How can I print a string (via Console.WriteLine()) such that any/all escape sequences that may exist in the string ...
Jed's user avatar
  • 10.9k
0 votes
2 answers
3k views

Possible Duplicate: Can I convert a C# string value to an escaped string literal I have a small program where I want the user to be able to put in escape characters like "\n\r" "\t", etc. Do I ...
user441521's user avatar
  • 7,038
5 votes
1 answer
3k views

Is there a C# method like Python's repr() to get the true representation of the object? Suppose we have: string identifier = "22\n44"; Console.WriteLine(identifier); This would return 22 44 Is ...
Animesh D's user avatar
  • 5,030
1 vote
1 answer
916 views

I have a string of assorted white-space: e.g. "\t\r " I need to display it in an error message, but just showing white-space isn't helpful. Is there a method to encode the string for displaying?
BanksySan's user avatar
  • 28.7k
0 votes
1 answer
1k views

Given this sample code: var s = "abc\r\ndef"; foreach (var c in s) { Console.WriteLine($"Current char: {c}"); } Of course, the '\r' and '\n' characters, are written as whitespace and an actual ...
jeroenh's user avatar
  • 26.9k
2 votes
3 answers
242 views

Possible Duplicate: Can I convert a C# string value to an escaped string literal How I can show the contents of a string in 'pure mode',including \r,\n,\t etc.. equivalent to .toSource() method of ...
The Mask's user avatar
  • 17.5k
0 votes
1 answer
493 views

I want to save a string to a file (without for example making \n into an actual new line). This is my code: using (var fs = new FileStream(path, FileMode.Truncate) { var sw = new StreamWriter(fs); ...
RadarDev's user avatar
0 votes
2 answers
323 views

Possible Duplicate: Can I convert a C# string value to an escaped string literal How can i entitize an arbitrary string to get exact human readable view similar to what the debugger does? I.e. i ...
UserControl's user avatar
  • 15.3k
0 votes
1 answer
303 views

I read this string: "\u0093 Safe area to answer the phone\u0094." But when i want to send or rewrite in files, it appears like this: " Safe area to answer the phone." I need to print the original ...
eljaquez's user avatar
2 votes
1 answer
111 views

When one wraps a string into an object and make that object ToString return that string, \0 is never shown: public void Test() { var a = "a"; var b = "\0"; var c = new ...
aybe's user avatar
  • 16.8k
0 votes
0 answers
55 views

I want to be able to see what characters a string is composed of, so how do I print a string containing '\t' and '\n' as "\\t" and "\\n" respectively? That is, I want to go in the opposite direction, ...
Matt Gregory's user avatar
  • 8,752
0 votes
0 answers
43 views

I currently have a UTF8 string that contains nulls, backspaces, etc. inside the string. I am trying to escape the string so that control characters are visible in their escaped form. Basically, the ...
Jeff Geisperger's user avatar
7 votes
7 answers
35k views

After running VeraCode, it reported a following error "Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Response Splitting')" in the following code fragment: protected override void ...
piterskiy's user avatar
  • 187
8 votes
5 answers
5k views

If I have a string that contains a c# string literal expression can I "expand" it at runtime public void TestEvaluateString() { string Dummy = EvalString( @"Contains \r\n new line"); ...
Andy Morris's user avatar
  • 3,533
13 votes
2 answers
6k views

This is sort of the Java analogue of this question about C#. Suppose I have a String object which I want to represent in code and I want to produce a string literal that maps to the same thing. ...
Simon Nickerson's user avatar

15 30 50 per page