C#用换行符编码文本字符串 [英] C# Encoding a text string with line breaks
问题描述
有没有人有这方面的经验?
谢谢
Jim
\\\
作为换行符,而不是 \r\\\
。记事本只能理解后者。 (请注意,其他人建议的 Environment.NewLine
如果您希望平台默认 - 但是如果您从Mono服务,并且肯定需要 \r\\\
,则应明确指定。)
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.
Has anyone had any experience with this?
Thanks
Jim
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.)
这篇关于C#用换行符编码文本字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!