Skip Menu |
 

This queue is for tickets about the DateTime-Calendar-Chinese CPAN distribution.

Report information
The Basics
Id: 14423
Status: new
Priority: 0/
Queue: DateTime-Calendar-Chinese

People
Owner: Nobody in particular
Requestors: sdiz [...] sdiz.net
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.05
Fixed in: (no value)



Subject: DateTime::Calendar::Chinese does not work well with other unicode perl program
Download (untitled) / with headers
text/plain 1.2k
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}", );
From: sdiz [...] sdiz.net
[guest - Fri Sep 2 13:46:56 2005]: Show quoted text
> 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 --
This is a better testcase: -- BEGIN TESTCASE -- use DateTime::Calendar::Chinese; use utf8; my $cc; my $dt = DateTime->now; $cc = DateTime::Calendar::Chinese->from_object(object => $dt); $chinese_year = $cc->year_name(); { use Lingua::ZH::Numbers 'traditional'; $chinese_month = Lingua::ZH::Numbers::number_to_zh( $cc->month() ). " Month"; #. $cc->day; } print $chinese_year . " Year " . $chinese_month . "\n"; -- END TESTCASE -- -- BEGIN OUTPUT (UTF-8) -- ä¹é Year 七 Month -- END OUTPUT (UTF-8) --


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.