in reply to Re^4: Perl6: Capturing newline in a string
in thread Perl6: Capturing newline in a string

Hi stevieb,

Just a bit of feedback. I have tried a number of things and combinations (such as using the :bin and chomp => false options, using the lines, slurp, slurp-rest and get functions or methods), etc., but to no avail. Even when requested to keep new lines, Perl 6 is apparently converting \r\n sequences to \n on reading a Windows file, so that "un-chomped" lines end with \x0A (or ASCII 10), whether they come from a Unix or a Windows file. There doesn't seem to be a possibility to distinguish between EOL conventions this way. Or, at least, I haven't found any.

Not a good news, and unfortunately not very helpful, but I thought I should let you know about my tests.

Replies are listed 'Best First'.
Re^6: Perl6: Capturing newline in a string
by stevieb (Canon) on May 31, 2016 at 23:05 UTC

    It's very helpful Laurent_R, thanks! Combined with what raiph said in Re^3: Perl6: Capturing newline in a string that I've reviewed, I'm thinking this is a bug (or at least a function that's lacking... I can't see me being the only person who will want to identify which endings a file has, as perl6 takes off).

    There should be a way to get this information, or else there's no way to ensure the proper line endings get replaced (by proper I mean the original ones) when the endings aren't that of the local platform.

    I'm going to do a bit more testing and review. If I can't figure anything out, I'll open a ticket.

      So don't use .lines and instead open(:bin) parse the Buf like you normally would. It's really pretty simple if you quit trying to use a higher level convenience method to do this
        I'd be glad i you could show a working example. From my (very limited) tests, even that does not appear to work. But perhaps I failed to use the right function.