Subject: | DateTime::Calendar::Chinese does not work well with other unicode perl program |
In Chinese.pm, the celestial_stem and terrestrial_branch are written as a sequence of bytes in UTF-8.
This prevent other modules that use new perl unicode interface in perl 5.6 (such as Lingua::ZH::Numbers) work properly with your module.
-- BEGIN TESTCASE --
use DateTime::Calendar::Chinese;
use utf8;
use encoding "utf-8";
my $dt = DateTime->now;
my $cc = DateTime::Calendar::Chinese->from_object(object => $dt);
print $cc->year_name() . "\n";
-- END TESTCASE --
(You _MUST_ use perl 5.6 or later)
Just view the output in a utf-8 terminal, and you will see how it breaks.
To save your time, here is the hex dump:
sdiz@xdeb:~/build/perl$ perl broken-unicode | xxd
0000000: c3a4 c2b9 c299 c3a9 c285 c289 0a .............
The expected output should be:
sdiz@xdeb:~/build/perl$ perl correct-unicode | xxd
0000000: e4b9 99e9 8589 0a .......
POSSIBLE FIX:
Specify the celestial_stem and terrestrial_branch arrays as \x{...} notations. This notations, akaik, only works from perl 5.6 onward.
e.g.
my @celestial_stems =
( "\x{7532}",
"\x{4e59}",
"\x{4e19}",
"\x{4e01}",
"\x{620a}",
"\x{5df1}",
"\x{5e9a}",
"\x{8f9b}",
"\x{58ec}",
"\x{7678}",
);