package I18N::Japanese;

=head1 NAME

Japanese - Perl pragma to control whether some built-in operations understand
    composite characters or not.

=head1 SYNOPSIS

use Japanese qw(re tr format);
nouse Japanese qw(re tr format);

=head1 DESCRIPTION

This module is actually a pragma module, though it begins with capital J.
Import/unimport takes list of strings.

=over 5
    
=re

    Enables Japanized regexp, including split.

=tr 

    Enables Japanized tr//.

=format

    Enables Japanized format.

=back

    As usual, omitting the arguments means specifying all the bits.
    The setting is valid only within the current block.
    
=cut

# ウラワザ : 0x8000000 は，文字列定数で2バイト文字を認識するかどうか
sub import {
    shift;
    my $bits = 0;
    @_ = qw(re tr format string) if (@_ == 0);
    for (@_) {
	$bits |= 0x1000000 if $_ eq 're';
	$bits |= 0x2000000 if $_ eq 'tr';
	$bits |= 0x4000000 if $_ eq 'format';
	$bits |= 0x8000000 if $_ eq 'string';
    }
#    $bits |= 0x8000000 if ($bits != 0);
    
    $^H |= $bits;
    #print "imp : hints = $bits\n";
}

sub unimport {
    shift;
    my $bits = 0;
    @_ = qw(re tr format string) if (@_ == 0);
    for (@_) {
	$bits |= 0x1000000 if $_ eq 're';
	$bits |= 0x2000000 if $_ eq 'tr';
	$bits |= 0x4000000 if $_ eq 'format';
	$bits |= 0x8000000 if $_ eq 'string';
    }
#    $bits = 0x8000000 if ($^H != 0x8000000 && $bits == 0);
    $^H &= ~$bits;
    #print "unimp : hints = $bits\n";
}

1;
