-
-
Notifications
You must be signed in to change notification settings - Fork 705
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File.byLine terminator string #9895
Labels
Comments
andrei (@andralex) commented on 2013-01-08T01:11:43ZThis is by design. The length name is special and defined to return size_t compulsively. You may want to choose a different name instead. |
andrei (@andralex) commented on 2013-01-08T01:12:15ZOops, wrong window. |
dlang-bugzilla (@CyberShadow) commented on 2013-03-16T01:40:03ZWould it be acceptable if we special-cased byLine to strip a trailing \r if the terminator is \n?
Often, the programmer doesn't know beforehand if the line terminator of a text file will be \r\n or \n. A behavior close to that of splitLines would be more useful than forcing the programmer to choose an exact terminator sequence. |
bearophile_hugs commented on 2013-03-17T17:44:06Z(In reply to comment #3)
> Would it be acceptable if we special-cased byLine to strip a trailing \r if the
> terminator is \n?
Probably the problem presented in this issue has various solutions. |
andrej.mitrovich (@AndrejMitrovic) commented on 2013-03-18T12:11:08Z*** Issue 9750 has been marked as a duplicate of this issue. *** |
nick (@ntrel) commented on 2013-08-08T07:18:09Zhttps://github.com/D-Programming-Language/phobos/pull/1458 |
github-bugzilla commented on 2013-08-11T19:19:36ZCommits pushed to master at https://github.com/D-Programming-Language/phobos
https://github.com/D-Programming-Language/phobos/commit/7f76586e16623894c7b6119014f76ed7bfef527e
Fix Issue 5378 - Make File.byLine accept a string terminator
Add an overload of byLine without a default argument for terminator.
Before, byLine!string tried to instantiate "string terminator = '\n'",
which is invalid.
Note: This removes the default arguments from ByLine.this, but the
constructor was never documented anyway (unlike the range primitives).
https://github.com/D-Programming-Language/phobos/commit/5576d899af510de798b0d5aaa8bd13e6caebfbce
Merge pull request #1458 from ntrel/byLine-crlf
Fix Issue 5378 - Make File.byLine accept a string terminator |
rumbu commented on 2021-02-11T08:37:04ZDefault behaviour is unexpected, at least on Windows where most files contain lines ended in \r\n.
Use of lineSeparator enum for cross platform development does not guarantee that the file you are processing contain only the lineSeparator terminator.
If I ask byLine, I expect to obtain a line not something else, not a line ended with another line terminator. What if my file contains some lines ended in \r and other line ended in \r\n?
Default behaviour must strip terminators and must consume all known line separators, there is no point to discriminate between them:
- 0x0d
- 0x0d\0x0a
- 0x0a
- Unicode categories Zl, Zp. |
|
This was fixed by #1458 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
bearophile_hugs reported this on 2010-12-26T07:11:51Z
Transfered from https://issues.dlang.org/show_bug.cgi?id=5378
CC List
Description
The text was updated successfully, but these errors were encountered: