Embedded Artistry libc
C Standard Library Support for Bare-metal Systems
langinfo.h File Reference
#include <nl_types.h>
Include dependency graph for langinfo.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ABDAY_1   0x20000
 
#define ABDAY_2   0x20001
 
#define ABDAY_3   0x20002
 
#define ABDAY_4   0x20003
 
#define ABDAY_5   0x20004
 
#define ABDAY_6   0x20005
 
#define ABDAY_7   0x20006
 
#define DAY_1   0x20007
 
#define DAY_2   0x20008
 
#define DAY_3   0x20009
 
#define DAY_4   0x2000A
 
#define DAY_5   0x2000B
 
#define DAY_6   0x2000C
 
#define DAY_7   0x2000D
 
#define ABMON_1   0x2000E
 
#define ABMON_2   0x2000F
 
#define ABMON_3   0x20010
 
#define ABMON_4   0x20011
 
#define ABMON_5   0x20012
 
#define ABMON_6   0x20013
 
#define ABMON_7   0x20014
 
#define ABMON_8   0x20015
 
#define ABMON_9   0x20016
 
#define ABMON_10   0x20017
 
#define ABMON_11   0x20018
 
#define ABMON_12   0x20019
 
#define MON_1   0x2001A
 
#define MON_2   0x2001B
 
#define MON_3   0x2001C
 
#define MON_4   0x2001D
 
#define MON_5   0x2001E
 
#define MON_6   0x2001F
 
#define MON_7   0x20020
 
#define MON_8   0x20021
 
#define MON_9   0x20022
 
#define MON_10   0x20023
 
#define MON_11   0x20024
 
#define MON_12   0x20025
 
#define AM_STR   0x20026
 
#define PM_STR   0x20027
 
#define D_T_FMT   0x20028
 
#define D_FMT   0x20029
 
#define T_FMT   0x2002A
 
#define T_FMT_AMPM   0x2002B
 
#define ERA   0x2002C
 
#define ERA_D_FMT   0x2002E
 
#define ALT_DIGITS   0x2002F
 
#define ERA_D_T_FMT   0x20030
 
#define ERA_T_FMT   0x20031
 
#define CODESET   14
 
#define CRNCYSTR   0x4000F
 
#define RADIXCHAR   0x10000
 
#define THOUSEP   0x10001
 
#define YESEXPR   0x50000
 
#define NOEXPR   0x50001
 
#define _NL_LOCALE_NAME(cat)   (((cat) << 16) | 0xffff)
 

Functions

char * nl_langinfo (nl_item item)
 

Macro Definition Documentation

◆ _NL_LOCALE_NAME

#define _NL_LOCALE_NAME (   cat)    (((cat) << 16) | 0xffff)

Definition at line 92 of file langinfo.h.

◆ ABDAY_1

#define ABDAY_1   0x20000

Definition at line 27 of file langinfo.h.

◆ ABDAY_2

#define ABDAY_2   0x20001

Definition at line 28 of file langinfo.h.

◆ ABDAY_3

#define ABDAY_3   0x20002

Definition at line 29 of file langinfo.h.

◆ ABDAY_4

#define ABDAY_4   0x20003

Definition at line 30 of file langinfo.h.

◆ ABDAY_5

#define ABDAY_5   0x20004

Definition at line 31 of file langinfo.h.

◆ ABDAY_6

#define ABDAY_6   0x20005

Definition at line 32 of file langinfo.h.

◆ ABDAY_7

#define ABDAY_7   0x20006

Definition at line 33 of file langinfo.h.

◆ ABMON_1

#define ABMON_1   0x2000E

Definition at line 43 of file langinfo.h.

◆ ABMON_10

#define ABMON_10   0x20017

Definition at line 52 of file langinfo.h.

◆ ABMON_11

#define ABMON_11   0x20018

Definition at line 53 of file langinfo.h.

◆ ABMON_12

#define ABMON_12   0x20019

Definition at line 54 of file langinfo.h.

◆ ABMON_2

#define ABMON_2   0x2000F

Definition at line 44 of file langinfo.h.

◆ ABMON_3

#define ABMON_3   0x20010

Definition at line 45 of file langinfo.h.

◆ ABMON_4

#define ABMON_4   0x20011

Definition at line 46 of file langinfo.h.

◆ ABMON_5

#define ABMON_5   0x20012

Definition at line 47 of file langinfo.h.

◆ ABMON_6

#define ABMON_6   0x20013

Definition at line 48 of file langinfo.h.

◆ ABMON_7

#define ABMON_7   0x20014

Definition at line 49 of file langinfo.h.

◆ ABMON_8

#define ABMON_8   0x20015

Definition at line 50 of file langinfo.h.

◆ ABMON_9

#define ABMON_9   0x20016

Definition at line 51 of file langinfo.h.

◆ ALT_DIGITS

#define ALT_DIGITS   0x2002F

Definition at line 79 of file langinfo.h.

◆ AM_STR

#define AM_STR   0x20026

Definition at line 69 of file langinfo.h.

◆ CODESET

#define CODESET   14

Definition at line 83 of file langinfo.h.

◆ CRNCYSTR

#define CRNCYSTR   0x4000F

Definition at line 85 of file langinfo.h.

◆ D_FMT

#define D_FMT   0x20029

Definition at line 73 of file langinfo.h.

◆ D_T_FMT

#define D_T_FMT   0x20028

Definition at line 72 of file langinfo.h.

◆ DAY_1

#define DAY_1   0x20007

Definition at line 35 of file langinfo.h.

◆ DAY_2

#define DAY_2   0x20008

Definition at line 36 of file langinfo.h.

◆ DAY_3

#define DAY_3   0x20009

Definition at line 37 of file langinfo.h.

◆ DAY_4

#define DAY_4   0x2000A

Definition at line 38 of file langinfo.h.

◆ DAY_5

#define DAY_5   0x2000B

Definition at line 39 of file langinfo.h.

◆ DAY_6

#define DAY_6   0x2000C

Definition at line 40 of file langinfo.h.

◆ DAY_7

#define DAY_7   0x2000D

Definition at line 41 of file langinfo.h.

◆ ERA

#define ERA   0x2002C

Definition at line 77 of file langinfo.h.

◆ ERA_D_FMT

#define ERA_D_FMT   0x2002E

Definition at line 78 of file langinfo.h.

◆ ERA_D_T_FMT

#define ERA_D_T_FMT   0x20030

Definition at line 80 of file langinfo.h.

◆ ERA_T_FMT

#define ERA_T_FMT   0x20031

Definition at line 81 of file langinfo.h.

◆ MON_1

#define MON_1   0x2001A

Definition at line 56 of file langinfo.h.

◆ MON_10

#define MON_10   0x20023

Definition at line 65 of file langinfo.h.

◆ MON_11

#define MON_11   0x20024

Definition at line 66 of file langinfo.h.

◆ MON_12

#define MON_12   0x20025

Definition at line 67 of file langinfo.h.

◆ MON_2

#define MON_2   0x2001B

Definition at line 57 of file langinfo.h.

◆ MON_3

#define MON_3   0x2001C

Definition at line 58 of file langinfo.h.

◆ MON_4

#define MON_4   0x2001D

Definition at line 59 of file langinfo.h.

◆ MON_5

#define MON_5   0x2001E

Definition at line 60 of file langinfo.h.

◆ MON_6

#define MON_6   0x2001F

Definition at line 61 of file langinfo.h.

◆ MON_7

#define MON_7   0x20020

Definition at line 62 of file langinfo.h.

◆ MON_8

#define MON_8   0x20021

Definition at line 63 of file langinfo.h.

◆ MON_9

#define MON_9   0x20022

Definition at line 64 of file langinfo.h.

◆ NOEXPR

#define NOEXPR   0x50001

Definition at line 90 of file langinfo.h.

◆ PM_STR

#define PM_STR   0x20027

Definition at line 70 of file langinfo.h.

◆ RADIXCHAR

#define RADIXCHAR   0x10000

Definition at line 87 of file langinfo.h.

◆ T_FMT

#define T_FMT   0x2002A

Definition at line 74 of file langinfo.h.

◆ T_FMT_AMPM

#define T_FMT_AMPM   0x2002B

Definition at line 75 of file langinfo.h.

◆ THOUSEP

#define THOUSEP   0x10001

Definition at line 88 of file langinfo.h.

◆ YESEXPR

#define YESEXPR   0x50000

Definition at line 89 of file langinfo.h.

Function Documentation

◆ nl_langinfo()

char* nl_langinfo ( nl_item  item)

The nl_langinfo function can be used to access individual elements of the locale categories. Unlike the localeconv function, which returns all the information, nl_langinfo lets the caller select what information it requires. This is very fast and it is not a problem to call this function multiple times.

A second advantage is that in addition to the numeric and monetary formatting information, information from the LC_TIME and LC_MESSAGES categories is available.

The type item is defined in nl_types.h. The argument item is a numeric value defined in this header.

Definition at line 64 of file langinfo.c.

65 {
66  int cat = item >> 16;
67  int idx = item & 65535;
68  const char* str;
69 
70  if(item == CODESET)
71  {
72  assert(0 /*"Codeset langinfo not implemented"*/);
73  // return loc->cat[LC_CTYPE] ? "UTF-8" : "ASCII";
74  }
75 
76  /* _NL_LOCALE_NAME extension */
77  if(idx == 65535 && cat < LC_ALL)
78  {
79  assert(0 /*"LOCALE_NAME langinfo not implemented"*/);
80  // return loc->cat[cat] ? (char *)loc->cat[cat]->name : "C";
81  }
82 
83  switch(cat)
84  {
85  case LC_NUMERIC:
86  if(idx > 1)
87  {
88  return (char*)(uintptr_t) "";
89  }
90  str = c_numeric;
91  break;
92  case LC_TIME:
93  if(idx > 0x31)
94  {
95  return (char*)(uintptr_t) "";
96  }
97  str = c_time;
98  break;
99  case LC_MONETARY:
100  if(idx > 0)
101  {
102  return (char*)(uintptr_t) "";
103  }
104  str = "";
105  break;
106  case LC_MESSAGES:
107  if(idx > 3)
108  {
109  return (char*)(uintptr_t) "";
110  }
111  str = c_messages;
112  break;
113  default:
114  return (char*)(uintptr_t) "";
115  }
116 
117  for(; idx; idx--, str++)
118  {
119  for(; *str; str++)
120  {
121  }
122  }
123 
124 #if 0
125  if (cat != LC_NUMERIC && *str)
126  {
127  str = LCTRANS(str, cat, loc);
128  }
129 #endif
130 
131  return (char*)(uintptr_t)str;
132 }
static const char c_time[]
Definition: langinfo.c:6
#define assert(x)
Definition: assert.h:11
static const char c_numeric[]
Definition: langinfo.c:61
#define CODESET
Definition: langinfo.h:83
static const char c_messages[]
Definition: langinfo.c:57
#define LC_MONETARY
Definition: locale.h:14
#define LC_ALL
Definition: locale.h:16
#define LC_TIME
Definition: locale.h:12
#define LC_NUMERIC
Definition: locale.h:11
#define LC_MESSAGES
Definition: locale.h:15

References assert, c_messages, c_numeric, c_time, CODESET, LC_ALL, LC_MESSAGES, LC_MONETARY, LC_NUMERIC, and LC_TIME.

Referenced by asctime_r().

Here is the caller graph for this function: