decode options?

Hi All,

Uhhh,

     https://docs.perl6.org/routine/decode

        role Blob

        From Blob
        (Blob) method decode

        Defined as:

        multi method decode(Blob:D: Str:D $encoding =3D 'UTF-8' --> Str:D=
)

        Applies an encoding to turn the blob into a Str.

        my Blob $blob =3D "string".encode('utf-8');
        say $blob.decode('utf-8'); # OUTPUT: =C2=ABstring=E2=90=A4=C2=BB

        On malformed utf-8 .decode will throw X::AdHoc. To handle
        sloppy utf-8 use utf8-c8.

where are the decode options?  I only see utf-8 and utf8-c8.
Am I blind?


Many thanks,
-T
0
perl6
2/4/2019 12:56:27 AM
perl.perl6.users 1159 articles. 0 followers. Follow

1 Replies
30 Views

Similar Articles

[PageSpeed] 4

On 2/3/19 4:56 PM, ToddAndMargo via perl6-users wrote:
> Hi All,
>=20
> Uhhh,
>=20
>  =C2=A0=C2=A0=C2=A0 https://docs.perl6.org/routine/decode
>=20
>  =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 role Blob
>=20
>  =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 From Blob
>  =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (Blob) method decode
>=20
>  =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Defined as:
>=20
>  =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 multi method decode(Blob:D: Str:D=
 $encoding =3D 'UTF-8' --> Str:D)
>=20
>  =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Applies an encoding to turn the b=
lob into a Str.
>=20
>  =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 my Blob $blob =3D "string".encode=
('utf-8');
>  =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 say $blob.decode('utf-8'); # OUTP=
UT: =C2=ABstring=E2=90=A4=C2=BB
>=20
>  =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 On malformed utf-8 .decode will t=
hrow X::AdHoc. To handle
>  =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sloppy utf-8 use utf8-c8.
>=20
> where are the decode options?=C2=A0 I only see utf-8 and utf8-c8.
> Am I blind?
>=20
>=20
> Many thanks,
> -T

Found it and I am not blind.  The Docs just stink.  I would
write an RFE for this, but, the odds of them accepting it are
so close to zero that it is not worth the effort.

And what is with?
      Str:D $encoding =3D 'UTF-8'

$encoding can accept a whole bunch of things.  And
What the heck is `'UTF-8'`?  It sure ain't "utf8" or
Rakudo's "utf-8".


My own docs:

https://docs.perl6.org/type/IO::Handle#___top

    utf8
    utf16
    utf16le
    utf16be
    utf8-c8
    iso-8859-1
    windows-1251
    windows-1252
    windows-932
    ascii

    Rakudo extensions:

       latin-1 (iso-8859-1)
       utf-8
       utf-16
0
perl6
2/4/2019 4:09:21 AM
Reply: