C# Encoding a text string with line breaks
Solution 1
Yes - it means you're using \n
as the line break instead of \r\n
. Notepad only understands the latter.
(Note that Environment.NewLine
suggested by others is fine if you want the platform default - but if you're serving from Mono and definitely want \r\n
, you should specify it explicitly.)
Solution 2
Use Environment.NewLine for line breaks.
Solution 3
Try this :
string myStr = ...
myStr = myStr.Replace("\n", Environment.NewLine)
Solution 4
Try \n\n , it will work! :)
public async Task AjudaAsync(IDialogContext context, LuisResult result){
await context.PostAsync("How can I help you? \n\n 1.To Schedule \n\n 2.Consult");
context.Wait(MessageReceived);
}
Solution 5
Also:
string s = $"first line{Environment.NewLine}second line";
![Simon Buchholz](https://lh4.googleusercontent.com/-HdsPkzT5jvY/AAAAAAAAAAI/AAAAAAAAAAA/AB6qoq0MZEnQWCttsaNPYJXhUTdKx5qZEA/mo/photo.jpg?sz=256)
Simon Buchholz
I type fast, attend meetings, drink coffee, nod my head vigorously and enjoy telling others what to do.
Updated on April 01, 2021Comments
-
Simon Buchholz about 3 years
I have a string I am writing to the outputstream of the response. After I save this document and open it in Notepad++ or WordPad I get nicely formatted line breaks where they are intended, but when I open this document with the regular old Windows Notepad, I get one long text string with □ (square like symbols) where the line breaks should be.
Has anyone had any experience with this?