diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2001-11-09 00:23:40 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-11-09 00:23:40 +0000 |
commit | ac5ea53171baa7dab1a92df1eacf8d2fe19cbdbb (patch) | |
tree | 5ce2221e6a7335594861f38233d4d665313a7c82 /ext/Unicode/Normalize/Normalize.pm | |
parent | 61a515a61510e728f2014674d12cb94cb5a90834 (diff) | |
download | perl-ac5ea53171baa7dab1a92df1eacf8d2fe19cbdbb.tar.gz |
Upgrade to Unicode::Normalize 0.10, now in XS.
The CPAN distribution has both pm and XS implementations,
and for performance reasons we choose the XS.
Another reason to choose the XS is that it doesn't
require Lingua::KO::Hangul::Util, which means that
we can delete that-- which in turn means that Unicode::UCD
cannot expect that: support it, but don't expect.
Ditto Unicode::Collate.
Note that Unicode::Normalize Makefile.PL and
Normalize.xs have been modified from the CPAN 0.10
versions: the first one to be simpler (no pm) and
clean up the generated unf*.h files, the second one
to quench compiler grumblings. Must notify Sadahiro
about these changes.
p4raw-id: //depot/perl@12909
Diffstat (limited to 'ext/Unicode/Normalize/Normalize.pm')
-rw-r--r-- | ext/Unicode/Normalize/Normalize.pm | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/ext/Unicode/Normalize/Normalize.pm b/ext/Unicode/Normalize/Normalize.pm new file mode 100644 index 0000000000..a583425a3b --- /dev/null +++ b/ext/Unicode/Normalize/Normalize.pm @@ -0,0 +1,45 @@ +package Unicode::Normalize; + +use 5.006; +use strict; +use warnings; +use Carp; + +our $VERSION = '0.10'; +our $PACKAGE = __PACKAGE__; + +require Exporter; +require DynaLoader; +require AutoLoader; + +our @ISA = qw(Exporter DynaLoader); +our @EXPORT = qw( NFC NFD NFKC NFKD ); +our @EXPORT_OK = qw( normalize decompose reorder compose + getCanon getCompat getComposite getCombinClass getExclusion); +our %EXPORT_TAGS = ( all => [ @EXPORT, @EXPORT_OK ] ); + +bootstrap Unicode::Normalize $VERSION; + +use constant CANON => 0; +use constant COMPAT => 1; + +sub NFD ($) { reorder(decompose($_[0], CANON)) } + +sub NFKD ($) { reorder(decompose($_[0], COMPAT)) } + +sub NFC ($) { compose(reorder(decompose($_[0], CANON))) } + +sub NFKC ($) { compose(reorder(decompose($_[0], COMPAT))) } + +sub normalize($$) +{ + my $form = shift; + $form eq 'D' || $form eq 'NFD' ? NFD ($_[0]) : + $form eq 'C' || $form eq 'NFC' ? NFC ($_[0]) : + $form eq 'KD' || $form eq 'NFKD' ? NFKD($_[0]) : + $form eq 'KC' || $form eq 'NFKC' ? NFKC($_[0]) : + croak $PACKAGE."::normalize: invalid form name: $form"; +} + +1; +__END__ |