Welcome to the Monastery | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Is there an sprintf implementation available for Perl that is independent of any numeric locale settings? i.e. where sprintf "%.2g", 3.1415926 returns 3.14 and not 3,14 on locales that use a comma as the radix character. For context, I recently hit issues with a Gtk2 interface to an application was setting the numeric locale to match a user's settings. The application uses sprintf to reduce the numeric precision of values to use as hash keys for a simple index, which then had knock-on effects when the index keys were used numerically. There were other locale effects, but that was the main one. That specific case is now avoided since I discovered Gtk2->disable_setlocale, and I do realise that numeric locales affect more than just sprintf, but it might still be useful to have a locale independent version. I found nothing when checking metacpan, but there look to be external libraries that allow one to specify a locale as an argument. In reply to A locale independent sprintf? by swl
|
|