NAME

Text::UnicodeStyle - replace Latin letters with lookalike characters from other Unicode ranges (mathematical alphanumeric symbols, etc.)

SYNOPSIS

use Text::UnicodeStyle qw( stylize styles );

say stylize('route_id', 'monospace');   # 𝐫𝐨𝐮𝐭𝐞_𝐢𝐝
say join ', ', styles();                # doublestruck, fraktur, ...

DESCRIPTION

stylize returns a copy of the input string where every ASCII letter A-Z and a-z is replaced by the corresponding character of the requested style. In styles that define digit mappings (bold, circled, doublestruck, fullwidth, monospace, parenthesized, sans_serif, sans_serif_bold) digits 0-9 are replaced as well; elsewhere they are left unchanged. In the fullwidth style all printable ASCII punctuation !-~ is mapped to its fullwidth form as well (including _); in all other styles punctuation is left unchanged. Spaces and already non-ASCII text are always left untouched.

Each style is defined by a base code point for uppercase and lowercase letters (either may be absent — e.g. squared, negative_circled and negative_squared only cover uppercase) plus an optional fix table of exceptions (characters whose Unicode position does not follow the contiguous range). Some styles also define a digit base code point, which enables substitution of digits 0-9 — currently bold, circled, doublestruck, fullwidth, monospace, parenthesized, sans_serif and sans_serif_bold. The fullwidth style additionally defines punct, an additive offset applied to printable ASCII characters not covered by the other keys. In all other styles digits and punctuation are left unchanged. Note that parenthesized has no glyph for digit 0, so it stays unchanged there. Style tables live in Text::UnicodeStyle::* modules and are loaded lazily.

FUNCTIONS

stylize($string, $style)

Returns a new string with letters substituted. Dies on unknown style. The input string is not modified.

styles()

Returns the sorted list of available style names.

STYLES

bold, bold_fraktur, bold_italic, bold_script
circled, doublestruck, fraktur, fullwidth
italic, monospace
negative_circled, negative_squared (uppercase only)
parenthesized
sans_serif, sans_serif_bold, sans_serif_bold_italic, sans_serif_italic
script
squared (uppercase only)

SEE ALSO

example.pl in the project repository for a runnable demo.

Project repository: https://github.com/shoorick/substitute-letters

Bug reports and other issues: https://github.com/shoorick/substitute-letters/issues

VERSION

This library version is 0.01.

LICENSE

https://opensource.org/licenses/MIT|MIT