Re: Substr behaviour with CRLF

2020-02-10 Thread David Santiago
Thanks for the help.

I do agree with Paul that something should be mentioned in the substr 
documentation.

David Santiago
-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.


Re: Substr behaviour with CRLF

2020-02-10 Thread Patrick R. Michaud
Because Str is treated as a set of graphemes, and "\r\n" is treated as a single 
character, .substr() is doing the right thing here.

If you really want to treat it as a series of codepoints, you may want to go 
through Blob/Buf to get there:

> "1234\r\n78".encode.subbuf(*-4)
utf8:0x<0D 0A 37 38>
> "1234\r\n78".encode.subbuf(*-4).decode

78

Pm


On Mon, Feb 10, 2020 at 02:38:19PM -0500, Paul Procacci wrote:
> Unicode conformance requires "\r\n" to be interpreted as \n alone.
> With that said; no, I don't not know how to turn this off.
> 
> I personally think I'd consider this a bug.  If not a bug, greater
> documentation efforts that explain this.
> The display routines (say / print) don't modify the string on output, yet
> the other string handling routines do.
> 
> We'd need further clarification from the devs as I don't have a full grasp
> of the design decision for this problem.
> 
> On Mon, Feb 10, 2020 at 11:28 AM David Santiago  wrote:
> 
> > A 10 de fevereiro de 2020 16:57:55 CET, David Santiago 
> > escreveu:
> > >
> > >
> > >Hi!
> > >
> > >Is there a way to change the the following behaviour, so it considers
> > \r\n as two characters when using substr, instead of one?
> > >
> > >On raku version 2019.11
> > >
> > >> "1234\r\n". substr(*-4)
> > >4
> > >78
> > >> "1234\r\n". substr(*-4).ords()
> > >(52 13 10 55 56)
> > >
> > >
> > >Best regards,
> > >David Santiago
> > >
> >
> > Copied wrong the example:
> >
> > It should be:
> >
> > On raku version 2019.11
> >
> > > "1234\r\n78". substr(*-4)
> > 4
> > 78
> > > "1234\r\n78". substr(*-4).ords()
> > (52 13 10 55 56)
> >
> >
> >
> > --
> > Sent from my Android device with K-9 Mail. Please excuse my brevity.
> >
> 
> 
> -- 
> __
> 
> :(){ :|:& };:


Re: Substr behaviour with CRLF

2020-02-10 Thread Paul Procacci
Unicode conformance requires "\r\n" to be interpreted as \n alone.
With that said; no, I don't not know how to turn this off.

I personally think I'd consider this a bug.  If not a bug, greater
documentation efforts that explain this.
The display routines (say / print) don't modify the string on output, yet
the other string handling routines do.

We'd need further clarification from the devs as I don't have a full grasp
of the design decision for this problem.

On Mon, Feb 10, 2020 at 11:28 AM David Santiago  wrote:

> A 10 de fevereiro de 2020 16:57:55 CET, David Santiago 
> escreveu:
> >
> >
> >Hi!
> >
> >Is there a way to change the the following behaviour, so it considers
> \r\n as two characters when using substr, instead of one?
> >
> >On raku version 2019.11
> >
> >> "1234\r\n". substr(*-4)
> >4
> >78
> >> "1234\r\n". substr(*-4).ords()
> >(52 13 10 55 56)
> >
> >
> >Best regards,
> >David Santiago
> >
>
> Copied wrong the example:
>
> It should be:
>
> On raku version 2019.11
>
> > "1234\r\n78". substr(*-4)
> 4
> 78
> > "1234\r\n78". substr(*-4).ords()
> (52 13 10 55 56)
>
>
>
> --
> Sent from my Android device with K-9 Mail. Please excuse my brevity.
>


-- 
__

:(){ :|:& };:


Re: Substr behaviour with CRLF

2020-02-10 Thread David Santiago
A 10 de fevereiro de 2020 16:57:55 CET, David Santiago  
escreveu:
>
>
>Hi!
>
>Is there a way to change the the following behaviour, so it considers \r\n as 
>two characters when using substr, instead of one?
>
>On raku version 2019.11
>
>> "1234\r\n". substr(*-4)
>4
>78
>> "1234\r\n". substr(*-4).ords()
>(52 13 10 55 56)
>
>
>Best regards,
>David Santiago
>

Copied wrong the example:

It should be:

On raku version 2019.11

> "1234\r\n78". substr(*-4)
4
78
> "1234\r\n78". substr(*-4).ords()
(52 13 10 55 56)



-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.