$plugin_purpose{'info-case'} =
  "Transform characters case in meta information flags";
$plugin_options{'info-case'} = [
  ['title performer songwriter arranger composer message',
    'Transform appropriate flag'],
  ['all', 'Transform all defined flags'],
  ['allupper', 'Make all characters uppercase'],
  ['alllower', 'Make all characters lowercase'],
  ['firstupper', 'Make first character uppercase'],
  ['wordupper', 'Make first character of each word uppercase']];

push(@info_plugin_hook, sub {
    my ($ti, $langs) = @_;
    my $opts = $plugin{'info-case'};
    my @flags = $$opts{all} ? @track_flags :
      grep({$$opts{lc($_)}} @track_flags);
    for my $fl(@flags) {
	next unless defined $ti->{$fl};
	for my $nl(0..$#$langs) {
	    next unless defined $ti->{$fl}->[$nl];
	    local($_) = decode(langinfo(CODESET()), $ti->{$fl}->[$nl]);
	    if ($$opts{allupper}) {
		$_ = uc($_);
	    } elsif ($$opts{alllower}) {
		$_ = lc($_);
	    } elsif ($$opts{firstupper}) {
		s/^(.)/uc($1)/e;
	    } elsif ($$opts{wordupper}) {
		s/\b(.)/uc($1)/ge;
	    }
	    $ti->{$fl}->[$nl] = encode(langinfo(CODESET()), $_);
	}
    }
});

1;

# vim:ft=perl
