Re: Fastest way to convert from a Buf to a Str?

2019-02-03 Thread ToddAndMargo via perl6-users
On 2/3/19 5:26 PM, Darren Duncan wrote: On 2019-02-02 7:22 PM, ToddAndMargo via perl6-users wrote: I need to read a file into a buffer (NO CONVERSIONS!) and then convert it to a string (again with no conversions). I think you're making an impossible request. Don't forget that I think

Re: Fastest way to convert from a Buf to a Str?

2019-02-03 Thread Darren Duncan
On 2019-02-02 7:22 PM, ToddAndMargo via perl6-users wrote: I need to read a file into a buffer (NO CONVERSIONS!) and then convert it to a string (again with no conversions). I think you're making an impossible request. If preserving exact bytes is important, then you want to keep your data

Re: Fastest way to convert from a Buf to a Str?

2019-02-03 Thread ToddAndMargo via perl6-users
On 2/3/19 1:55 AM, David Warring wrote: Are all characters in the range 0-255, ie latin-1 characters? You could then try: my $str =  $buf.decode("latin-1"); There's one potential  issue if your data could contain DOS end of lines ("\r\n"), which will get translated to a single logical "\n" in

Re: Fastest way to convert from a Buf to a Str?

2019-02-03 Thread David Warring
Are all characters in the range 0-255, ie latin-1 characters? You could then try: my $str = $buf.decode("latin-1"); There's one potential issue if your data could contain DOS end of lines ("\r\n"), which will get translated to a single logical "\n" in the decoded string. - David On Sun, Feb

Re: Fastest way to convert from a Buf to a Str?

2019-02-02 Thread ToddAndMargo via perl6-users
> > On Sat, Feb 2, 2019 at 9:23 PM ToddAndMargo via perl6-users > wrote: >> >> Hi All, >> >> I need to read a file into a buffer (NO CONVERSIONS!) >> and then convert it to a string (again with no >> conversions). >> >> I have been doing this: >> >> for ( @$BinaryFile ) -> $Char { $StrFile

Re: Fastest way to convert from a Buf to a Str?

2019-02-02 Thread Brad Gilbert
This: for ( @$BinaryFile ) -> $Char { $StrFile ~= chr($Char); } is better written as my $StrFile = $BinaryFile.map(*.chr).reduce(* ~ *); It is also exactly equivalent to just e # if $BinaryFile is a Buf my $StrFile = $BinaryFile.decode('latin1'); # if it isn't my