Linked Questions
46 questions linked to/from Can I convert a C# string value to an escaped string literal?
5
votes
1
answer
7k
views
How to force Console.WriteLine() to print verbatim strings? [duplicate]
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 ...
0
votes
2
answers
3k
views
C# escape characters in user input [duplicate]
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 ...
5
votes
1
answer
3k
views
C# equivalent of Python repr() [duplicate]
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 ...
1
vote
1
answer
916
views
Encode\escape string for .NET [duplicate]
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?
0
votes
1
answer
1k
views
How to convert string or character to 'escaped representation'? [duplicate]
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 ...
2
votes
3
answers
242
views
C# equivalent to toSource() of javascript [duplicate]
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 ...
0
votes
1
answer
493
views
(C#) How can I get a string with escape characters without changing the escape characters? [duplicate]
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);
...
0
votes
2
answers
323
views
Entitize arbitrary .NET string [duplicate]
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 ...
0
votes
1
answer
303
views
How to print string exactly as it is read from a file? [duplicate]
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 ...
2
votes
1
answer
111
views
Get an object's ToString() to show up '\0' for a string that's a null character? [duplicate]
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 ...
0
votes
0
answers
55
views
Converting control characters to escape sequences in C# [duplicate]
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, ...
0
votes
0
answers
43
views
Escape a UTF8 string's control characters [duplicate]
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 ...
7
votes
7
answers
35k
views
How to fix "Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Response Splitting')"
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 ...
8
votes
5
answers
5k
views
Can I expand a string that contains C# literal expressions at runtime
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");
...
13
votes
2
answers
6k
views
How would you convert a String to a Java string literal?
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.
...