Skip to contentSkip to conversation

nl_langinfo.3: better explaination

PATCH In review Michael Haardt 2 participants 2 messages Sep 28, 2010 – Oct 3, 2010 1 message not in the archive Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nl_langinfo.3: better explaination

Hello,

it could be more clear that nl_langinfo() interacts with setlocale(). I made a patch against 3.27 and added a short example to query the terminal character set.

Michael
----------------------------------------------------------------------

nl_langinfo.3 renamed from nl_langinfo.3.orig +22 -2
@@ -10,8 +10,9 @@
 .\"   OpenGroup's Single Unix specification http://www.UNIX-systems.org/online.html
 .\"
 .\" Corrected prototype, 2002-10-18, aeb
+.\" Modified 2010-09-28 by Michael Haardt
 .\"
-.TH NL_LANGINFO 3  2001-05-11 "GNU" "Linux Programmer's Manual"
+.TH NL_LANGINFO 3 "GNU" "Linux Programmer's Manual"
 .SH NAME
 nl_langinfo \- query language and locale information
 .SH SYNOPSIS
@@ -97,7 +98,9 @@
 For a more detailed list, consult
 .IR "The GNU C Library Reference Manual" .
 .SH "RETURN VALUE"
-If no locale has been selected for the appropriate category,
+If no locale has been selected by
+.BR setlocale ()
+for the appropriate category,
 .BR nl_langinfo ()
 returns a pointer to the corresponding string in the
 "C" locale.
@@ -109,6 +112,23 @@
 .BR nl_langinfo ()
 or
 .BR setlocale (3).
+.SH "EXAMPLE"
+This program sets the character type locale according to the
+environment and queries the terminal character set.
+.LP
+.nf
+#include <langinfo.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char *argv[])
+{
+  setlocale(LC_CTYPE,"");
+  printf("%s\\n",nl_langinfo(CODESET));
+  exit(EXIT_SUCCESS);
+}
+.fi
 .SH "CONFORMING TO"
 SUSv2, POSIX.1-2001.
 .SH "SEE ALSO"

--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

Hello Michael.

Quoted 5 lines · Michael Haardt

Hello,

it could be more clear that nl_langinfo() interacts with setlocale(). I made a patch against 3.27 and added a short example to query the terminal character set.

Thanks. Applied for man-pages-3.28.

Cheers,

Michael

Quoted 51 lines

Michael
----------------------------------------------------------------------

nl_langinfo.3     2010-09-28 13:33:26.000000000 +0200 renamed from nl_langinfo.3.orig        2010-09-28 13:14:39.000000000 +0200 +0 -0
@@ -10,8 +10,9 @@

 .\"   OpenGroup's Single Unix specification http://www.UNIX-systems.org/online.html
 .\"
 .\" Corrected prototype, 2002-10-18, aeb
+.\" Modified 2010-09-28 by Michael Haardt
 .\"
-.TH NL_LANGINFO 3  2001-05-11 "GNU" "Linux Programmer's Manual"
+.TH NL_LANGINFO 3 "GNU" "Linux Programmer's Manual"
 .SH NAME
 nl_langinfo \- query language and locale information
 .SH SYNOPSIS

nl_langinfo.3     2010-09-28 13:33:26.000000000 +0200 renamed from nl_langinfo.3.orig        2010-09-28 13:14:39.000000000 +0200 +0 -0
@@ -97,7 +98,9 @@

 For a more detailed list, consult
 .IR "The GNU C Library Reference Manual" .
 .SH "RETURN VALUE"

nl_langinfo.3     2010-09-28 13:33:26.000000000 +0200 renamed from nl_langinfo.3.orig        2010-09-28 13:14:39.000000000 +0200 +3 -1
-If no locale has been selected for the appropriate category,
+If no locale has been selected by
+.BR setlocale ()
+for the appropriate category,

 .BR nl_langinfo ()
 returns a pointer to the corresponding string in the "C" locale.

nl_langinfo.3     2010-09-28 13:33:26.000000000 +0200 renamed from nl_langinfo.3.orig        2010-09-28 13:14:39.000000000 +0200 +0 -0
@@ -109,6 +112,23 @@
  .BR nl_langinfo ()

 or
 .BR setlocale (3).
+.SH "EXAMPLE"

nl_langinfo.3     2010-09-28 13:33:26.000000000 +0200 renamed from nl_langinfo.3.orig        2010-09-28 13:14:39.000000000 +0200 +16 -0
+This program sets the character type locale according to the
+environment and queries the terminal character set.
+.LP
+.nf
+#include <langinfo.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char *argv[])
+{
+  setlocale(LC_CTYPE,"");
+  printf("%s\\n",nl_langinfo(CODESET));
+  exit(EXIT_SUCCESS);
+}
+.fi

 .SH "CONFORMING TO"
 SUSv2, POSIX.1-2001.
 .SH "SEE ALSO"

Signature · 7 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Author of "The Linux Programming Interface"; http://man7.org/tlpi/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html