Re: [w3c/FileAPI] Add BlobPropertyBag.endings back to the spec. (#90)

annevk commented on this pull request.



> +
+    Note: The {{Blob/type}} of the {{Blob}} array element is ignored and will not affect {{Blob/type}} of returned
+    {{Blob}} object.
+
+1. Return |bytes|.
+
+</div>
+
+<div algorithm="convert-line-endings-to-native">
+To <dfn lt="convert line endings to native|converting line endings to native">
+convert line endings to native</dfn> in a [=string=] |s|,
+run the following steps:
+
+1. Let |native line ending| be be the [=code point=] U+000A LF,
+  or the [=code point=] U+000D CR followed by the [=code point=] U+000A,
+  as determined by the underlying platform's conventions.

Maybe also say that if there are different conventions it has to be LF?

> +
+    Note: The {{Blob/type}} of the {{Blob}} array element is ignored and will not affect {{Blob/type}} of returned
+    {{Blob}} object.
+
+1. Return |bytes|.
+
+</div>
+
+<div algorithm="convert-line-endings-to-native">
+To <dfn lt="convert line endings to native|converting line endings to native">
+convert line endings to native</dfn> in a [=string=] |s|,
+run the following steps:
+
+1. Let |native line ending| be be the [=code point=] U+000A LF,
+  or the [=code point=] U+000D CR followed by the [=code point=] U+000A,
+  as determined by the underlying platform's conventions.

E.g., by setting it to LF and only overwriting it to CR LF if the platform conventions are that.

> +1. While |position| is not past the end of |s|:
+
+  1. If the [=code point=] at |position| within |s| equals U+000D CR
+    and the [=code point=] at |position|+1 within |s| equals U+000A LF,
+    advance |position| by 2 and append |native line ending| to |result|.
+
+  1. If the [=code point=] at |position| within |s| equals U+000A LF,
+    advance |position| by 1 and append |native line ending| to |result|.
+
+  1. Let |token| be the result of [=collecting a sequence of code points=]
+    that are not equal to U+000A LF or U+000D CR
+    from |s| given |position|.
+
+  1. Append |token| to |result|.
+
+1. Return |result|.

I think it would be okay to say something like "Replace any occurrence of LF, CR LF, or CR with _native_."

It seems your algorithm doesn't consider a lone CR a line ending. I'd assume browsers do treat it as such. Is that tested?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/FileAPI/pull/90#pullrequestreview-79811913

Received on Wednesday, 29 November 2017 11:21:34 UTC