NL_LANGINFO(3am)

πŸ“¦
version 1.1.0 Β· 2 versions
, in fedora 43, fedora 44

✨ NL_LANGINFO(3am) ✨

okay bestie, we're doing a GNU Awk Extension Modules page today and it's honestly a little cutie πŸ’– it's the nl_langinfo extension and it's here to make your awk speak every language on earth. periodt.


🌸 NAME 🌸

nl_langinfo</p> β€” retrieve locale-specific information strings πŸ¦‹


πŸŽ€ SYNOPSIS πŸŽ€

@load "nl_langinfo"

result = nl_langinfo(LANGINFO["variable"])

πŸ’… DESCRIPTION πŸ’…

so. the nl_langinfo extension gives AWK a whole interface to the C library routine nl_langinfo(3). the way it does that is it adds two things:

  • a single function named nl_langinfo()
  • an array named LANGINFO

The single argument in a call to nl_langinfo() should be one of the available values in the LANGINFO array. yes bestie, literally one arg, that's the whole vibe check.

The return value is the requested string, or the empty string if an error occurred πŸ™ˆ (no exceptions, no drama, just an empty string, so keep an eye out).

The indices of LANGINFO are the names of various available strings as given in the POSIX standard: see http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/langinfo.h.html. For example, "D_T_FMT" is the current locale's date and time format for use with strftime(3). See the standard for the full list β€” it's giving ✨reference material✨, iykyk.


πŸ”₯ EXAMPLE πŸ”₯

@load "nl_langinfo"

# print the time and date in the locale's format
BEGIN {
    print strftime(nl_langinfo(LANGINFO["D_T_FMT"]))
}

not me printing the date in whatever locale the user happens to be in, no cap, that's main character energy πŸ‘‘


🌈 SEE ALSO 🌈


πŸ’œ AUTHOR πŸ’œ

Arnold Robbins, arnold@skeeve.com.


πŸ‘‘ COPYING PERMISSIONS πŸ‘‘

Copyright Β© 2012, 2013, Free Software Foundation, Inc. Copyright Β© 2015, Arnold David Robbins.

Permission is granted to make and distribute verbatim copies of this manual page provided the copyright notice and this permission notice are preserved on all copies.

Permission is granted to copy and distribute modified versions of this manual page under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.

Permission is granted to copy and distribute translations of this manual page into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Foundation.

⚠️ yes this whole block is the legal bit and it is non-negotiable β€” keep the notices intact, bestie, that's the rules πŸ’€

okay that's the whole page, mwah πŸ’‹ this one's from the Jun 01 2015 era of the GNU Awk Extension Modules docs 🫢 go forth and be locale-aware, slay πŸ’–βœ¨

πŸ“¦ where this page comes from