Function: locale-info
locale-info is a function defined in fns.c.
Signature
(locale-info ITEM)
Documentation
Access locale data ITEM for the current C locale, if available.
ITEM should be one of the following:
codeset, returning the character set as a string (locale item CODESET);
days, returning a 7-element vector of day names (locale items DAY_n);
months, returning a 12-element vector of month names (locale items MON_n);
paper, returning a list of 2 integers (WIDTH HEIGHT) for the default
paper size, both measured in millimeters (locale items _NL_PAPER_WIDTH,
_NL_PAPER_HEIGHT).
If the system can't provide such information through a call to
nl_langinfo, or if ITEM isn't from the list above, return nil.
See also Info node (libc)Locales.
The data read from the system are decoded using locale-coding-system.
Probably introduced at or before Emacs version 22.1.
Source Code
// Defined in /usr/src/emacs/src/fns.c
{
char *str = NULL;
/* STR is apparently unused on Android. */
((void) str);
#ifdef HAVE_LANGINFO_CODESET
if (EQ (item, Qcodeset))
{
str = nl_langinfo (CODESET);
return build_string (str);
}
# ifdef DAY_1
if (EQ (item, Qdays)) /* E.g., for calendar-day-name-array. */
{
Lisp_Object v = make_nil_vector (7);
const int days[7] = {DAY_1, DAY_2, DAY_3, DAY_4, DAY_5, DAY_6, DAY_7};
int i;
synchronize_system_time_locale ();
for (i = 0; i < 7; i++)
{
str = nl_langinfo (days[i]);
AUTO_STRING (val, str);
/* Fixme: Is this coding system necessarily right, even if
it is consistent with CODESET? If not, what to do? */
ASET (v, i, code_convert_string_norecord (val, Vlocale_coding_system,
0));
}
return v;
}
# endif
# ifdef MON_1
if (EQ (item, Qmonths)) /* E.g., for calendar-month-name-array. */
{
Lisp_Object v = make_nil_vector (12);
const int months[12] = {MON_1, MON_2, MON_3, MON_4, MON_5, MON_6, MON_7,
MON_8, MON_9, MON_10, MON_11, MON_12};
synchronize_system_time_locale ();
for (int i = 0; i < 12; i++)
{
str = nl_langinfo (months[i]);
AUTO_STRING (val, str);
ASET (v, i, code_convert_string_norecord (val, Vlocale_coding_system,
0));
}
return v;
}
# endif
# ifdef HAVE_LANGINFO__NL_PAPER_WIDTH
if (EQ (item, Qpaper))
/* We have to cast twice here: first to a correctly-sized integer,
then to int, because that's what nl_langinfo is documented to
return for _NO_PAPER_{WIDTH,HEIGHT}. The first cast doesn't
suffice because it could overflow an Emacs fixnum. This can
happen when running under ASan, which fills allocated but
uninitialized memory with 0xBE bytes. */
return list2i ((int) (intptr_t) nl_langinfo (_NL_PAPER_WIDTH),
(int) (intptr_t) nl_langinfo (_NL_PAPER_HEIGHT));
# endif
#endif /* HAVE_LANGINFO_CODESET*/
return Qnil;
}