brian d foy > Roman-Unicode-1.02 > Roman::Unicode

Download:
Roman-Unicode-1.02.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 1.02   Source   Latest Release: Roman-Unicode-1.03

NAME ^

Roman::Unicode - Make roman numerals, using the Unicode characters for them

SYNOPSIS ^

        use Roman::Unicode qw( to_roman is_roman to_perl );

        my $perl_number  = to_perl( $roman ) if is_roman( $roman );
        my $roman_number = to_roman( $arabic );

DESCRIPTION ^

I made this module as a way to demonstrate various Unicode things without mixing up natural language stuff. Surprisingly, roman numerals can do quite a bit with that.

Functions

is_roman

Returns true if the string looks like a valid roman numeral. This works with either the ASCII version or the ones using the characters in the U+2160 to U+2188 range.

to_perl( ROMAN )

If the argument is a valid roman numeral, to_perl returns the Perl number. Otherwise, it returns nothing.

to_roman( PERL_NUMBER )

If the argument is a valid Perl number, even if it is a string, to_roman returns the roman numeral representation. This uses the characters in the U+2160 to U+2188 range.

If the number cannot be represented as roman numerals, this returns nothing. Note that 0 doesn't have a roman numeral representation.

If you want the lowercase version, you can use lc on the result. However, some of the roman numerals don't have lowercase versions.

to_ascii( ROMAN )

If the argument is a valid roman numeral, it returns an ASCII representation of it. For characters that have ASCII representations, it uses those ASCII characters. For other characters, it uses ASCII art representations:

        Roman       ASCII art
        ------      ----------
        ↂ          (C)
        ↈ          ((C))
        ↇ           (D)
IsRoman
IsLowercaseRoman
IsUppercaseRoman

These define special properties to quickly match the characters this module considers valid Roman numerals.

LIMITATIONS ^

By using just the defined roman numerals characters in the Unicode Character Set, you're limited to numbers less than 400,000 (although you could make ↈↈↈↈ if you wanted, since that's not unheard of).

AUTHOR ^

brian d foy <brian.d.foy@gmail.com> 2011-

This module started with the Roman module, credited to:

OZAWA Sakuro <ozawa at aisoft.co.jp> 1995-1997

Alexandr Ciornii, <alexchorny at gmail.com> 2007

COPYRIGHT ^

Copyright (c) 2011, brian d foy.

You can use this module under the same terms as Perl itself.

syntax highlighting: