Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

character-sets [rt.cpan.org #80306] #3

Open
toddr opened this issue Jan 22, 2021 · 0 comments
Open

character-sets [rt.cpan.org #80306] #3

toddr opened this issue Jan 22, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@toddr
Copy link

toddr commented Jan 22, 2021

Migrated from rt.cpan.org#80306 (status was 'new')

Requestors:

From [email protected] on 2012-10-20 22:42:12
:

Hi,

Perl is very good in handling character-sets... if you follow one very
simple rule: on any place where characters enter of leave the program
you have to be very explicit.  IMO, digesting strings is a kind of
output filter.

Digest ignores the character-set problem.  For instance, if I read text
from a file which contains äø as valid latin1 and I digest that, I will
get a different digest from the same characters as autf8.  The problem is
that my latin1 string might automatically be converted into utf8!  The
programmer does not always know whether Perl converts the input data.

The solution would be to add an explicit character-set on new()

  Digest->new('SHA-1', encoding => 'utf8')

to specify which charset the text must be in to be signed.  When
specified, it should call Encode::encode.  When not specified, it
should croak when the utf-8 flag is on: it should be interpreted as
raw bytes.

The work-around is

  $digest->add(encode 'utf8', $text)

for every call to add.  The "utf8" information is wrongly located,
because add() is not about output.

I hope you will consider this improvement.


@toddr toddr added the enhancement New feature or request label Aug 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant