Replace names in strings with unicode chars
Perl
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
lib/Unicode/CharNames
t
.gitignore
Changes
README.mkdn
dist.ini

README.mkdn

NAME

Unicode::CharNames::Replace - Replace unicode charnames with characters at runtime

VERSION

version 0.001

SYNOPSIS

use Unicode::CharNames::Replace qw( replace_charnames );

my $str = replace_charnames($input, \%options);

DESCRIPTION

This module provides functions for replacing unicode character names with their corresponding characters at runtime.

The charnames pragma provides a way to place "\N{CHARNAME}" into strings, but it does this at compile time. This module will search for character names in strings created dynamically during your program's execution, for example, from user input.

The use-case that was the impetus for this module is the provided unirep script which replaces charnames with characters from @ARGV or <STDIN>.

OPTIONS

The following options can be passed to "replace_charnames" (or specified during import):

  • delimited - Replaces delimited character names in the string.

This will find sequences like "\N{CHARNAME}" and replace them with unicode characters much like charnames.

"i \N{HEAVY BLACK HEART} perl" => "i ❤ perl"
  • bare - Replaces bare character names found in the string.

Character name sequences do not need to be delimited:

"i HEAVY BLACK HEART perl" => "i ❤ perl"
  • insensitive - Matches names in a case-insensitive manner.

    "i heavy black heart perl" => "i ❤ perl"

  • noboundaries - Does not require charnames to occur at word boundaries.

    "iheavy black heartperl" => "i❤perl"

SEE ALSO

  • unirep - Command line version that works like echo or cat

TODO

  • relax perl version requirement (currently 5.14)
  • Rename methods
  • Document methods
  • Create OO interface
  • Probably replace Sub::Exporter with a simple closure around an OO instance
  • Allow for escaping the opening delimiter?
  • If delimited item is not exact, try matching as a regexp
  • By default ignore non-printing characters (CHARACTER TABULATION, LINE FEED (LF), SPACE, NULL) to avoid confusion
  • aliases? is this necessary beyond the alias functionality of charnames?
  • get list of aliases from charnames for replace_bare
  • a set of default aliases (heart, poo, razzberry)?
  • options for limiting charnames to specfied scripts/blocks?
  • options for matching omitted (specified) prefix?
  • move app into package to make it easy to wrap: use charnames :alias => ...; Unicode::Charnames::Replace::App->run;

SUPPORT

Perldoc

You can find documentation for this module with the perldoc command.

perldoc Unicode::CharNames::Replace

Websites

The following websites have more information about this module, and may be of help to you. As always, in addition to those websites please use your favorite search engine to discover more resources.

  • Search CPAN

The default CPAN search engine, useful to view POD in HTML format.

http://search.cpan.org/dist/Unicode-CharNames-Replace

  • RT: CPAN's Bug Tracker

The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN.

http://rt.cpan.org/NoAuth/Bugs.html?Dist=Unicode-CharNames-Replace

  • CPAN Ratings

The CPAN Ratings is a website that allows community ratings and reviews of Perl modules.

http://cpanratings.perl.org/d/Unicode-CharNames-Replace

  • CPAN Testers

The CPAN Testers is a network of smokers who run automated tests on uploaded CPAN distributions.

http://www.cpantesters.org/distro/U/Unicode-CharNames-Replace

  • CPAN Testers Matrix

The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms.

http://matrix.cpantesters.org/?dist=Unicode-CharNames-Replace

  • CPAN Testers Dependencies

The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution.

http://deps.cpantesters.org/?module=Unicode::CharNames::Replace

Bugs / Feature Requests

Please report any bugs or feature requests by email to bug-unicode-charnames-replace at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Unicode-CharNames-Replace. You will be automatically notified of any progress on the request by the system.

Source Code

https://github.com/rwstauner/Unicode-CharNames-Replace

git clone https://github.com/rwstauner/Unicode-CharNames-Replace.git

AUTHOR

Randy Stauner rwstauner@cpan.org

COPYRIGHT AND LICENSE

This software is copyright (c) 2011 by Randy Stauner.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.