Comments (4)
I don't like this very much, even on Windows if you open a file in text mode then you'll get \r\n
conversion. The more general thing is then splitting, which we should do by integrating or extending the split package for ByteString (and Text).
Leaving this open for discussion though.
from bytestring.
It would be really useful to have unlinesUniversal
or even patch unlines
to handle \r
too because the current implementation violates the principle of least astonishment.
The intuition any beginner Haskeller gets from using the lines
function for String
is that it returns proper lines without the \r
character. You'll write a code assuming that ByteString
's version of lines
works in a cross-platform way.
I'd be happy to send a PR if the maintainers are fine with it. I wasted half a day finding a bug in a parser only to find that it was working under the assumption that the lines
function strips away the \r
as well for Windows. I hope to prevent this for anyone else in the future.
There should at least be a line in the documentation in bold letters saying that lines
doesn't strip off \r
because that's very important to know.
from bytestring.
The intuition any beginner Haskeller gets from using the
lines
function forString
is that it returns proper lines without the\r
character.
I cannot find any special treatment for \r
in Data.List.lines
:
> lines "foo\r\nbar"
["foo\r","bar"]
So Data.ByteString.lines
is in line with its Prelude
counterpart. This behaviour has been recently reflected in the documentation. A general splitOn
function is discussed in #100.
I'm in favor of closing this.
from bytestring.
I agree with closing this issue.
from bytestring.
Related Issues (20)
- isValidUtf8 is broken HOT 4
- Compatibility with GHC's JavaScript backend HOT 1
- Overhaul Data.ByteString.Builder.RealFloat HOT 5
- Float and Double standard with precision 0 outputs incorrectly HOT 2
- Positive and Negative Zero Print Incorrect Precision
- Guidelines for using with WriterT HOT 2
- RealFloat Zero Padded Exponent HOT 7
- Faster Printing for Known Normal and Subnormal IEEE754 Floating Point Values
- Broken links in haddocks of `ShortByteString` HOT 1
- Audit `foreign import ccall` types
- Drop support for GHCs older than 8.4 HOT 1
- Add a splice of ShortByteString builder
- 0.12.1.0 fails to build on darwin aarch64 with GHC-8.10.7 HOT 13
- Create strict bytestrings from FixedPrim with zero copy HOT 6
- Lazy `zip` is stricter than expected
- unsafeUseAsCString(Len) may return a NULL pointer. HOT 9
- Document that `Data.ByteString.Lazy.appendFile` is not threadsafe.
- Eq and Ord for Builder
- Offer conversion with `Natural`. HOT 1
- Fixed Point Rounding
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bytestring.