标准换行符 [英] Standard newline character

查看:90
本文介绍了标准换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新线是否会标准化?我最近发现,在一个

textarea中,Internet Explorer为你输入的每一个换行添加了\\\\ n,

而firefox添加了\ n。我知道\ r也在某些地方使用过......将会修复这个问题吗?

解决方案

On星期一,2008年10月13日00:27:49 -0700(PDT),bgold12< bg ***** @ gmail.comwrote:


>将换行永远标准化?我最近发现,在一个
textarea中,Internet Explorer为你输入的每一个换行添加\\\\ n,而firefox添加了\ n。我知道\ r也在某些地方使用过......会不会有这个问题?



否; windows使用\\\\ n,Mac使用\ r和unix + linux使用\ n

为新换行:)我在处理文本区域时发现它最好是过滤器

所有控制字符到空格然后删除dup''d空格,摆脱恶作剧

并很好地重新格式化。


Grant。

-
http:// bugsplatter .id.au /


2008年10月13日星期一00:27:49 -0700,bgold12写道:


新标准是否会被标准化?我最近发现在一个

textarea中,Internet Explorer为你输入的每一个换行添加了\\\\ n,而

firefox添加了\ n。我知道\ r在某些地方也被使用过......这件事会不会被修复?



它们已经标准化了。


您通过网络发送或接收的所有文本都必须使用\\\ n。


您在C中读取或写入的所有文本都使用\ n。


如果您使用的是某种解释性语言(例如javascript) ),阅读

手册,为你的口译员查看它遵循的标准。


viza写道:


2008年10月13日星期一00:27:49 -0700,bgold12写道:


>换行标准是否会被标准化?我最近发现,在一个
textarea中,Internet Explorer为你输入的每一个换行添加\\\\ n,而firefox添加了\ n。我知道\ r也在某些地方使用过......会不会有这个问题?



它们已经标准化了。



确实如此。有很多标准可供选择,所以没有人需要

是非标准的!


您通过网络发送或接收的所有文本都必须使用\\ n。



不正确。没有这样的标准。互联网邮件标题具有

互联网标准,但这只是标题,而不是例如HTML或表单数据。


您在C中读取或写入的所有文本都使用\ n。



与主题不正确且无关。


关于HTML,请参阅HTML规范。他们指定,部分

有点懒散,浏览器应该或将接受任何CR,LF和

CR LF作为行尾。

问题是关于textarea元素的表单数据。那里有

标准说浏览器应该将行尾标准化为CR LF(

就是你所说的\\\\ n,这不是HTML符号或

metanotation )。


我刚测试了Firefox的行为方式,并且在输入换行符时正确发送CR LF(编码为

%0D%0A) textarea的。所以原来的问题

可能反映了一种误解或误解。


-

Yucca, http://www.cs.tut.fi/~jkorpela/


Will newlines ever be standardized? I recently discovered that in a
textarea, internet explorer adds \r\n for every newline you enter,
while firefox adds \n. I know \r is also used in some places... will
this ever be fixed?

解决方案

On Mon, 13 Oct 2008 00:27:49 -0700 (PDT), bgold12 <bg*****@gmail.comwrote:

>Will newlines ever be standardized? I recently discovered that in a
textarea, internet explorer adds \r\n for every newline you enter,
while firefox adds \n. I know \r is also used in some places... will
this ever be fixed?

No; windows uses \r\n, Mac uses \r and unix + linux do it right with \n
for a newline :) I find when processing text areas it''s best to filter
all control chars to spaces then remove dup''d spaces, gets rid of nasties
and reformats the thing nicely.

Grant.
--
http://bugsplatter.id.au/


On Mon, 13 Oct 2008 00:27:49 -0700, bgold12 wrote:

Will newlines ever be standardized? I recently discovered that in a
textarea, internet explorer adds \r\n for every newline you enter, while
firefox adds \n. I know \r is also used in some places... will this ever
be fixed?

They are already standardized.

All text that you send or receive over the network must use \r\n.

All text that you read or write in C uses \n.

If you are using some interpreted language (eg javascript), read the
manual for your interpreter to see which standard it follows.


viza wrote:

On Mon, 13 Oct 2008 00:27:49 -0700, bgold12 wrote:

>Will newlines ever be standardized? I recently discovered that in a
textarea, internet explorer adds \r\n for every newline you enter,
while firefox adds \n. I know \r is also used in some places... will
this ever be fixed?


They are already standardized.

Indeed they are. There are many standards to choose from, so nobody needs to
be nonstandard!

All text that you send or receive over the network must use \r\n.

Not correct. There is no such standard. Internet message headers have an
Internet-standard, but that''s just headers, not e.g. HTML or form data.

All text that you read or write in C uses \n.

Incorrect and irrelevant to the topic.

Regarding HTML, consult the HTML specifications. They specify, partly
somewhat sloppily, that browsers should or shall accept any of CR, LF, and
CR LF as end of line.

The question was about form data from textarea elements. There the
"standard" says that browsers shall canonicalize line ends to CR LF (which
is what you seem to mean by \r\n, which is _not_ an HTML notation or
metanotation).

I just tested how Firefox behaves, and it correctly sends CR LF (encoded as
%0D%0A) when a newline is entered in a textarea. So the original question
probably reflects a misunderstand or misinterpretation.

--
Yucca, http://www.cs.tut.fi/~jkorpela/


这篇关于标准换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆