I was wondering if there is a way to replace all instances of CRLF with '\n'. Is there a way to accomplish that?
What have you tried that is not working? CRLF means carriage return, line feed. Carriage return is \r
, line feed is \n
so replacing CRLF with line feed would be
value = value.Replace("\r\n", "\n");
This is just like any other string replace. It is important to note that Replace is a method which returns a new string, so you need to assign the result back to some variable, in most cases it will probably be the same variable name you were already using.
Edit: based on your comment below, you are probably mistaking CRLF for LF based on Notepad++'s end of line conversion setting. Open your file in a hex editor to see what is really there. You will see CRLF as 0D 0A
(so carriage return is 0D
and line feed is 0A
).
Notepad++ will show you what you want to see. Checked your end of line conversion by clicking Edit > EOL Conversion > UNIX Format
and it will show LF instead of CRLF, even if a CRLF is there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With