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
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
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
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
>
> 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
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