dankogai / p5-encode

Encode - character encodings (for Perl 5.8 or better)
https://metacpan.org/release/Encode
37 stars 51 forks source link

find_encoding returns Internal encoding #157

Closed Rikkuru closed 3 years ago

Rikkuru commented 3 years ago

Hi I caught an error " Unknown encoding 'Internal' " in call to from_to with encoding object returned from find_encoding. Here is an example:

perl -e 'use strict; use warnings; use Encode; my $enc = Encode::find_encoding("Unicode"); Encode::from_to("abc", $enc->name, "utf-8");'

I think Internal encoding obj should not be returned if it cant be used.

pali commented 3 years ago

It is caused by following code, which defines Unicode encoding via Internal package. https://github.com/dankogai/p5-encode/blob/67f59dd4092c12043182e427dfaa5abd5c791e58/Encode.pm#L176-L217

And I'm not sure what if purpose of that code. Because it contains following implementation of encode and decode methods: https://github.com/dankogai/p5-encode/blob/67f59dd4092c12043182e427dfaa5abd5c791e58/Encode.pm#L210-L216

@dankogai would probably know more why it is needed...

dankogai commented 3 years ago

Even I cannot recall what this code was for but since it is w/ UTF_EBCDIC this code existed BEFORE I took over the maintainer from late Nick Ing-Simmons. Luckily virtually no one used Unicode as encoding names till this report. Since Unicode is not a name of encoding, this code should be removed.

dankogai commented 3 years ago

Done. https://github.com/dankogai/p5-encode/commit/06591f7920dc3af57b98b03934ea881b5566962b Unicode is no longer a valid encoding name, as it should be.