funny characters in Date::Pcalc

C

cartercc

Installed Steffen Beyer's Date::pcalc from CPAN.

Wrote a little test program to see if it works and ran WITH WARNINGS:

1 #!/usr/bin/perl
2 use strict;
3 use Date::pcalc;
4
5 my ($doy,$year,$month,$date,$day);
6
7 print "Enter year:\n";
8 $year = <STDIN>;
9 chomp $year;
10 print "The year is $year.\n";
11
12 exit();

Test program worked but I got much more than I bargained for. I know
what's going on but have no idea how to fix it. Ideas?

Here's a SAMPLE of the output-----------------------------
Malformed UTF-8 character (unexpected non-continuation byte 0x6f,
immediately after start byte 0xe7) at
/usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm line 158.
Malformed UTF-8 character (unexpected non-continuation byte 0x72,
immediately after start byte 0xe9) at
/usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm line 191.
Malformed UTF-8 character (unexpected non-continuation byte 0x62,
immediately after start byte 0xe1) at
/usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm line 192.
Malformed UTF-8 character (unexpected non-continuation byte 0x61,
immediately after start byte 0xe7) at
/usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm line 195.
Malformed UTF-8 character (unexpected non-continuation byte 0x62,
immediately after start byte 0xe1) at
/usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm line 196.
Malformed UTF-8 character (1 byte, need 3, after start byte 0xec) at
/usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm line 203.
Malformed UTF-8 character (1 byte, need 3, after start byte 0xec) at
/usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm line 203.
Malformed UTF-8 character (1 byte, need 3, after start byte 0xec) at
/usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm line 203.
Malformed UTF-8 character (1 byte, need 3, after start byte 0xec) at
/usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm line 204.
Malformed UTF-8 character (1 byte, need 3, after start byte 0xec) at
/usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm line 204.
Malformed UTF-8 character (unexpected continuation byte 0xaa, with no
preceding start byte) at /usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm
line 229.
Malformed UTF-8 character (unexpected continuation byte 0xaa, with no
preceding start byte) at /usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm
line 229.
Malformed UTF-8 character (unexpected continuation byte 0xaa, with no
preceding start byte) at /usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm
line 229.
Malformed UTF-8 character (unexpected continuation byte 0xaa, with no
preceding start byte) at /usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm
line 229.
Malformed UTF-8 character (unexpected continuation byte 0xaa, with no
preceding start byte) at /usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm
line 229.
Malformed UTF-8 character (unexpected non-continuation byte 0x62,
immediately after start byte 0xe1) at
/usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm line 229.
Malformed UTF-8 character (unexpected non-continuation byte 0x61,
immediately after start byte 0xe7) at
/usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm line 254.
Malformed UTF-8 character (unexpected non-continuation byte 0x6f,
immediately after start byte 0xf1) at
/usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm line 254.
Malformed UTF-8 character (unexpected non-continuation byte 0x73,
immediately after start byte 0xea) at
/usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm line 255.
Enter year:
2006
The year is 2006.
[cal@serdev cal]$
 
D

Dave

Installed Steffen Beyer's Date::pcalc from CPAN.

Wrote a little test program to see if it works and ran WITH WARNINGS:

1 #!/usr/bin/perl
2 use strict;
3 use Date::pcalc;
4
5 my ($doy,$year,$month,$date,$day);
6
7 print "Enter year:\n";
8 $year = <STDIN>;
9 chomp $year;
10 print "The year is $year.\n";
11
12 exit();

Test program worked but I got much more than I bargained for. I know
what's going on but have no idea how to fix it. Ideas?

Here's a SAMPLE of the output-----------------------------
Malformed UTF-8 character (unexpected non-continuation byte 0x6f,
immediately after start byte 0xe7) at
/usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm line 158.
Malformed UTF-8 character (unexpected non-continuation byte 0x72,
immediately after start byte 0xe9) at
/usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm line 191.
Malformed UTF-8 character (unexpected non-continuation byte 0x62,
immediately after start byte 0xe1) at
/usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm line 192.
Malformed UTF-8 character (unexpected non-continuation byte 0x61,
immediately after start byte 0xe7) at
/usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm line 195.
Malformed UTF-8 character (unexpected non-continuation byte 0x62,
immediately after start byte 0xe1) at
/usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm line 196.
Malformed UTF-8 character (1 byte, need 3, after start byte 0xec) at
/usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm line 203.
Malformed UTF-8 character (1 byte, need 3, after start byte 0xec) at
/usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm line 203.
Malformed UTF-8 character (1 byte, need 3, after start byte 0xec) at
/usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm line 203.
Malformed UTF-8 character (1 byte, need 3, after start byte 0xec) at
/usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm line 204.
Malformed UTF-8 character (1 byte, need 3, after start byte 0xec) at
/usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm line 204.
Malformed UTF-8 character (unexpected continuation byte 0xaa, with no
preceding start byte) at /usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm
line 229.
Malformed UTF-8 character (unexpected continuation byte 0xaa, with no
preceding start byte) at /usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm
line 229.
Malformed UTF-8 character (unexpected continuation byte 0xaa, with no
preceding start byte) at /usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm
line 229.
Malformed UTF-8 character (unexpected continuation byte 0xaa, with no
preceding start byte) at /usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm
line 229.
Malformed UTF-8 character (unexpected continuation byte 0xaa, with no
preceding start byte) at /usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm
line 229.
Malformed UTF-8 character (unexpected non-continuation byte 0x62,
immediately after start byte 0xe1) at
/usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm line 229.
Malformed UTF-8 character (unexpected non-continuation byte 0x61,
immediately after start byte 0xe7) at
/usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm line 254.
Malformed UTF-8 character (unexpected non-continuation byte 0x6f,
immediately after start byte 0xf1) at
/usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm line 254.
Malformed UTF-8 character (unexpected non-continuation byte 0x73,
immediately after start byte 0xea) at
/usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm line 255.
Enter year:
2006
The year is 2006.
[cal@serdev cal]$

The source file is in ISO-8859-1 encoding, but the perl interpreter seems to
be assuming that it is utf-8, so every time it reaches an accented character
it complains. Try converting the source file to utf-8. (I found that pasting
the source into VIM on Windows XP and saving it produced the conversion).

Dave
 
D

David Squire

Installed Steffen Beyer's Date::pcalc from CPAN.

Wrote a little test program to see if it works and ran WITH WARNINGS:

1 #!/usr/bin/perl
2 use strict;

I do not see "use warnings;" here, despite what you say above.
3 use Date::pcalc;
4
5 my ($doy,$year,$month,$date,$day);
6
7 print "Enter year:\n";
8 $year = <STDIN>;
9 chomp $year;
10 print "The year is $year.\n";
11
12 exit();

Test program worked but I got much more than I bargained for. I know
what's going on but have no idea how to fix it. Ideas?

Here's a SAMPLE of the output-----------------------------
Malformed UTF-8 character (unexpected non-continuation byte 0x6f,
immediately after start byte 0xe7) at
/usr/lib/perl5/site_perl/5.8.0/Date/Pcalc.pm line 158.

[snip]

Did you type your year in a terminal? If so, is your terminal providing
ASCII or UTF8 as input format? Many recent linuces provide UTF-8, and I
would guess that perhaps your perl (or Date::pcalc) is not expecting that.

I just downloaded the package from CPAN and tested your script, getting:
./test.pl
Enter year:
1986
The year is 1986.

What happens if you add "binmode STDIN;" before your line 8?

DS
 
D

David Squire

David said:
Did you type your year in a terminal? If so, is your terminal providing
ASCII or UTF8 as input format? Many recent linuces provide UTF-8, and I
would guess that perhaps your perl (or Date::pcalc) is not expecting that.

Or indeed vice-versa.

DS
 
D

Dave

David Squire said:
Or indeed vice-versa.

DS

This is not relevant as utf-8 is a effectively superset of ascii and simple
numbers are the same in both. The warnings are being produced by the line:
use Date::pCalc;

The issue is with a conflict between the encoding of the source file for
Date::pCalc and what Perl is expecting (which may be influenced by
enviroment variables on the OP's machine).

Dave
 
C

cartercc

I do not see "use warnings;" here, despite what you say above.

$perl -w caltest.plx

CC
 
C

cartercc

Since I needed Date::pcalc to work, I edited the pm to remove (or
comment out) all the funny characters, so I'm a happy camper. And since
I use English only, the funny characters are not an issue.

This is like solving a chess problem by upsetting the board -- but it
worked.

Thanks, CC.
 
P

Peter J. Holzer

Dave said:
Installed Steffen Beyer's Date::pcalc from CPAN.

Wrote a little test program to see if it works and ran WITH WARNINGS:

1 #!/usr/bin/perl
2 use strict;
3 use Date::pcalc; [...]
Here's a SAMPLE of the output-----------------------------
Malformed UTF-8 character (unexpected non-continuation byte 0x6f,
immediately after start byte 0xe7) at
[...]

The source file is in ISO-8859-1 encoding, but the perl interpreter
seems to be assuming that it is utf-8, so every time it reaches an
accented character it complains. Try converting the source file to
utf-8.

If you do, you should probably also add

use utf8;

near the top. Or alternatively, you can leave it in ISO-8859-1 encoding
and add

use encoding 'iso-8859-1';

instead. You may also want to send a bug report to the author.
(I found that pasting the source into VIM on Windows XP and
saving it produced the conversion).

Or just open the file with vim (vim usually guesses the charset right),
then :set fileencoding=utf-8 and save the file again.

hp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top