in reply to Perl CGI UTF8 AND CHAP PASSWORD VERIFICATION

Browsers will usually encode the data they send back in the same encoding as the original page was in. So I would check whether you get your parameters in Windows-1251. If so, just decode from there to utf-8.

  • Comment on Re: Perl CGI UTF8 AND CHAP PASSWORD VERIFICATION

Replies are listed 'Best First'.
Re^2: Perl CGI UTF8 AND CHAP PASSWORD VERIFICATION
by kaloyan_iliev (Initiate) on Feb 03, 2011 at 17:28 UTC
    Hi, As I say I try to decode the CGI params:
    use Encode; my $chapid = CGI::param('chap-id'); my $chapchalange = CGI::param('chap-challenge'); $chapid = Encode::decode('CP1251', $chapid, Encode::FB_CROAK); $chapchalange = Encode::decode('CP1251', $chapchalange, Encode::FB_CRO +AK);
    The only thing that changes is this:
    ---------print chapid to STDERR----------------- \027 ---------Dump chapid before decode---------- SV = PVMG(0x80d0988e8) at 0x80d3234e0 REFCNT = 1 FLAGS = (PADMY,POK,pPOK) IV = 0 NV = 0 PV = 0x80d35f118 "\\027"\0 CUR = 4 LEN = 8 ---------Dump chapid after decode---------- SV = PVMG(0x80d0988e8) at 0x80d3234e0 REFCNT = 1 FLAGS = (PADMY,POK,pPOK,UTF8) IV = 0 NV = 0 PV = 0x80d35f5d8 "\\027"\0 [UTF8 "\\027"] CUR = 4 LEN = 8
    If I change the encoding in 'decode' from 'CP1251' to 'UTF-8' nothing really happens.
    Best regards,
    Kaloyan Iliev