[Jprogramming] utf8 and latin-1 code plane
Elijah Stone
elronnd at elronnd.net
Tue Mar 22 23:47:25 UTC 2022
It's not; it should give exactly the same result.
Distributing 8 u: over ::, we get (8 u: 9&u:) :: (8 u: 10&u:). The RHS of
adverse behaves the same as 8 u: 10 u: ] (from the original formulation).
The LHS decodes and then re-encodes its argument. Compare with the
original: 9&u: ] ]. This is an identity function which, as a side effect,
decodes its argument, throwing if the decode fails. But the result of the
decode is thrown away; if the input is a 1-byte char, the result will be
too.
Put another way: (9&u: ] ]) y ←→ (9 u: y) ] ]y ←→ ]y ←→ y (modulo effects).
On Tue, 22 Mar 2022, Raul Miller wrote:
> On Tue, Mar 22, 2022 at 7:16 PM Elijah Stone <elronnd at elronnd.net> wrote:
>> (Alternately, slower but shorter and clearer: 8 u: (9&u:) :: (10&u:).)
>
> And, the result is significantly more compact, which makes a
> difference when working with large volumes of text.
>
> Thanks again,
>
> --
> Raul
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list