繁体   English   中英

VS2003中的“ \\ r \\ n”或environment.newline无法用于IE11或Chrome

[英]“\r\n” or environment.newline in VS2003 not working for IE11 or chrome

VS2003尝试了"\\r\\n"和environment.newline来获取换行符。 我们正在使用"\\r\\n"或environment.newline在stringbuilder中编写文本,并将其保存在IO文件中。 在IE11中打开文件时,换行符在文件中不起作用,而在记事本中打开时,换行符则起作用。 如果在IE8较早版本中打开它,它也将起作用。

代码的一部分是:

 StringBuilder cdataDescription = new StringBuilder();

 cdataDescription.Append("* This is an install activity which passed through SYR.").Append(newline);
                cdataDescription.Append("\r\n");
                //For CSI
                cdataDescription.Append(" Please dispatch to the IBG  * ");
                cdataDescription.Append("\r\n");
                cdataDescription.AppendLine();
                cdataDescription.Append("test");
                cdataDescription.Append("\r\n");
                cdataDescription.Append("General Information");
                cdataDescription.Append("\r\n");
                cdataDescription.Append("---------------------------------------");
                cdataDescription.Append("\r\n");

string result = string.empty;
result = cdataDescription.ToString();

return result;

理想情况下,只要考虑编写文本文件,换行符应为“ \\ n”。 您可能需要检查用于写入文件的字符集。 Windows记事本仅支持ASCII,您可能会在Norepad ++中打开文件,因为它支持不同的字符集。

也要注意UNIX和Windows风格。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM