in C# 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, when I open this document with the regular old windows notepad, I get one long text string with [] square looking symbols where the line breaks should be.
在C#中,我有一个字符串,我正在写入响应的输出流。保存此文档并在Notepad ++或写字板中打开后,我得到了格式良好的换行符,当我用常规旧的Windows记事本打开此文档时,我得到一个带有[]方形符号的长文本字符串所在的行休息应该是。
Has anyone had any experience with this?
有没有人有这方面的经验?
Thanks
Jim
4 个解决方案
#1
Yes - it means you're using \n
as the line break instead of \r\n
. Notepad only understands the latter.
是的 - 这意味着您使用\ n作为换行而不是\ r \ n。记事本只能理解后者。
(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.)
(请注意,如果您希望平台默认设置,其他人建议使用Environment.NewLine是好的 - 但如果您从Mono提供服务并且肯定想要\ r \ n,则应明确指定它。)
#3
Try this :
试试这个 :
string myStr = ...
myStr = myStr.Replace("\n", Environment.NewLine)
#4
Try \n\n , it will work! :)
尝试\ n \ n,它会工作! :)
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);
}
#1
Yes - it means you're using \n
as the line break instead of \r\n
. Notepad only understands the latter.
是的 - 这意味着您使用\ n作为换行而不是\ r \ n。记事本只能理解后者。
(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.)
(请注意,如果您希望平台默认设置,其他人建议使用Environment.NewLine是好的 - 但如果您从Mono提供服务并且肯定想要\ r \ n,则应明确指定它。)
#2
Use Environment.NewLine for line breaks.
使用Environment.NewLine进行换行。
#3
Try this :
试试这个 :
string myStr = ...
myStr = myStr.Replace("\n", Environment.NewLine)
#4
Try \n\n , it will work! :)
尝试\ n \ n,它会工作! :)
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);
}