I have the following string :
This is the string to
test carriage return
using c#
The above string has two carriage returns in the end of lines. I have to encode this string to pass to a WCF service and then decode the string for further process.
//TO ENCODE
byte[] bytes = Encoding.Default.GetBytes(rawstring);
string encodedStr = Encoding.UTF8.GetString(bytes);
//TO DECODE
byte[] rawUtf8EncodedData = Encoding.Default.GetBytes(encodedstring);
string decodedStr = Encoding.UTF8.GetString(rawUtf8EncodedData);
After Encoding I get the below string :
This is the string to\ntest carriage return\nusing c#
After Decoding I get the below string :
This is the string to\ntest carriage return\nusing c#
Problem is, I need the carriage return back for some reason and not the \n in my string after decoding. How can I achieve this ? The above string is only for illustration and in actual string, there would be lots of carriage returns and symbols