NAME

IRC::Toolkit::Case - IRC case-folding utilities

SYNOPSIS

  use IRC::Toolkit::Case;

  my $lower = lc_irc( $string, 'rfc1459' );

  my $upper = uc_irc( $string, 'ascii' );

  if (eq_irc($first, $second, 'strict-rfc1459')) {
    ...
  }

  # Or use the '|rfc1459|' operator if using RFC1459 rules:
  if ($first |rfc1459| $second) {

  }

DESCRIPTION

IRC case-folding utilities.

IRC daemons typically announce their casemap in ISUPPORT (via the CASEMAPPING directive). This should be one of rfc1459, strict-rfc1459, or ascii:

  'ascii'           a-z      -->  A-Z
  'rfc1459'         a-z{}|^  -->  A-Z[]\~   (default)
  'strict-rfc1459'  a-z{}|   -->  A-Z[]\

If told to convert/compare an unknown casemap, these functions will warn and default to RFC1459 rules.

If you're building a class that tracks an IRC casemapping and manipulates strings accordingly, you may also want to see IRC::Toolkit::Role::CaseMap.

rfc1459 operator

The infix operator |rfc1459| is provided as a convenience for string comparison (using RFC1459 rules):

  if ($first |rfc1459| $second) { ... }
  # Same as:
  if (eq_irc($first, $second)) { ... }

lc_irc

Takes a string and an optional casemap.

Returns the lowercased string.

uc_irc

Takes a string and an optional casemap.

Returns the uppercased string.

eq_irc

Takes a pair of strings and an optional casemap.

Returns boolean true if the strings are equal (per the rules specified by the given casemap).

irc_str

  my $str = irc_str( strict => 'Nick^[Abc]' );
  if ( $str eq 'nick^{abc}' ) {
    # true
  }

Takes a casemap and string; if only one argument is provided, it is taken to be the string and a rfc1459 casemap is assumed.

Produces overloaded objects (see IRC::Toolkit::Case::MappedString) that can be stringified or compared; string comparison operators use the specified casemap.

AUTHOR

Jon Portnoy <avenj@cobaltirc.org>

Inspired by IRC::Utils, copyright Chris Williams, Hinrik et al

Licensed under the same terms as Perl.