Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some fancy currency symbols #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions Format.pm
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,38 @@ our @IGNORE_NEGATIVE = qw( frac_digits int_frac_digits
n_cs_precedes n_sep_by_space n_sign_posn
p_xs_precedes p_sep_by_space p_sign_posn );

#
# Some fancy currency symbols
#
our %currency_symbols = (
US_DOLLAR => '$',
EURO_CURRENCY => '₠',
COLON => '₡',
CRUZEIRO => '₢',
FRENCH_FRANC => '₣',
LIRA => '₤',
MILL => '₥',
NAIRA => '₦',
PESETA => '₧',
RUPEE => '₨',
WON => '₩',
NEW_SHEQEL => '₪',
DONG => '₫',
EURO => '€',
KIP => '₭',
TUGRIK => '₮',
DRACHMA => '₯',
GERMAN_PENNY_SYMBOL => '₰',
PESO => '₱',
GUARANI => '₲',
AUSTRAL => '₳',
HRYVNIA => '₴',
CEDI => '₵',
LIVRE_TOURNOIS => '₶',
TENGE => '₸',
INDIAN_RUPEE => '₹',
);

#
# Largest integer a 32-bit Perl can handle is based on the mantissa
# size of a double float, which is up to 53 bits. While we may be
Expand Down
1 change: 1 addition & 0 deletions t/format_picture.t
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ is($x->format_picture(-123456789.51, $pic), 'US$-**,***,***.**', 'neg over');
is($x->format_picture(1023012.34, $pic), 'US$ 1,023,012.34', 'million');
is($x->format_picture(120450.789012, $pic), 'US$ 120,450.79', 'pos rnd');
is($x->format_picture(-120450.789012, $pic),'US$ -120,450.79', 'neg rnd');
is($x->format_picture(1002.11, sprintf("%s #,###.##", $Number::Format::currency_symbols{NEW_SHEQEL})), '₪ 1,002.11', 'Number with New Sheqel');
$x->{neg_format} = '(x)';
is($x->format_picture(120450.789012, $pic), 'US$ 120,450.79 ', 'pos paren');
is($x->format_picture(-120450.789012, $pic),'US$ (120,450.79)', 'neg paren');
Expand Down