For Programmers: Free Programming Magazines  


Home > Archive > AWK > November 2004 > Calling "setlocale()" from GAWK (Was: Re: awk challenge)









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Calling "setlocale()" from GAWK (Was: Re: awk challenge)
Kenny McCormack

2004-11-23, 3:55 am

In article <419c872c@news.012.net.il>,
Aharon Robbins <arnold@skeeve.com> wrote:
>In article <ykPmd.6493$3U4.143215@news02.tsnz.net>,
>Don Stokes <don@daedalus.co.not-this-bit.nz> wrote:
>
>I still think it's best done with a shell wrapper. You're the only
>one to request it so far, in the almost 4 years since 3.1.0 and
>the i18n features were released.


I have developed an extension (shared lib) to GAWK called "call_any", that
allows you to call "any" (for some definition of any) C library function
from AWK. So, call_any is more useful than a dedicated way to call
setlocale().

Here is an example, that speaks to this thread topic:

% gawk 'BEGIN {extension(ENVIRON["HOME"]"/lib/call_any.so","dlload")
print "Locale is now:",call_any("sis","setlocale",6,"pt_BR")
s=" "
print call_any("isisd","strfmon",s,10,"%n",45.156);print s}'
Locale is now: pt_BR
3
£ 45
%

For fun, you can try this with other locales - en_US, en_GB, etc.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com