Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
9b75dca1
Kaydet (Commit)
9b75dca1
authored
Agu 10, 2001
tarafından
Martin v. Löwis
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Expose nl_langinfo through locale where available.
üst
09379da7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
229 additions
and
1 deletion
+229
-1
liblocale.tex
Doc/lib/liblocale.tex
+119
-0
aliases.py
Lib/encodings/aliases.py
+2
-0
_localemodule.c
Modules/_localemodule.c
+103
-0
configure
configure
+0
-0
configure.in
configure.in
+2
-1
pyconfig.h.in
pyconfig.h.in
+3
-0
No files found.
Doc/lib/liblocale.tex
Dosyayı görüntüle @
9b75dca1
...
...
@@ -108,6 +108,15 @@ locale.setlocale(locale.LC_ALL, '')
\end{tableii}
\end{funcdesc}
\begin{funcdesc}
{
nl
_
langinfo
}{
option
}
Return some locale-specific information as a string. This function is
not available on all systems, and the set of possible options might
also vary across platforms. The possible argument values are numbers,
for which symbolic constants are available in the locale module.
\end{funcdesc}
\begin{funcdesc}
{
getdefaultlocale
}{
\optional
{
envvars
}}
Tries to determine the default locale settings and returns
them as a tuple of the form
\code
{
(
\var
{
language code
}
,
...
...
@@ -259,6 +268,116 @@ locale.setlocale(locale.LC_ALL, '')
\function
{
localeconv()
}
.
\end{datadesc}
The
\function
{
nl
_
langinfo
}
function accepts one of the following keys.
Most descriptions are taken from the corresponding description in the
GNU C library.
\begin{datadesc}
{
CODESET
}
Return a string with the name of the character encoding used in the
selected locale.
\end{datadesc}
\begin{datadesc}
{
D
_
T
_
FMT
}
Return a string that can be used as a format string for strftime(3) to
represent time and date in a locale-specific way.
\end{datadesc}
\begin{datadesc}
{
D
_
FMT
}
Return a string that can be used as a format string for strftime(3) to
represent a date in a locale-specific way.
\end{datadesc}
\begin{datadesc}
{
T
_
FMT
}
Return a string that can be used as a format string for strftime(3) to
represent a time in a locale-specific way.
\end{datadesc}
\begin{datadesc}
{
T
_
FMT
_
AMPM
}
The return value can be used as a format string for `strftime' to
represent time in the am/pm format.
\end{datadesc}
\begin{datadesc}
{
DAY
_
1 ... DAY
_
7
}
Return name of the n-th day of the week.
\[
Warning: this follows the US
convention DAY
_
1
=
Sunday, not the international convention
(
ISO
8601
)
that Monday is the first day of the week.
\]
\end{datadesc}
\begin{datadesc}
{
ABDAY
_
1 ... ABDAY
_
7
}
Return abbreviated name of the n-th day of the week.
\end{datadesc}
\begin{datadesc}
{
MON
_
1 ... MON
_
12
}
Return name of the n-th month.
\end{datadesc}
\begin{datadesc}
{
ABMON
_
1 ... ABMON
_
12
}
Return abbreviated name of the n-th month.
\end{datadesc}
\begin{datadesc}
{
RADIXCHAR
}
Return radix character (decimal dot, decimal comma, etc.)
\end{datadesc}
\begin{datadesc}
{
THOUSEP
}
Return separator character for thousands (groups of three digits).
\end{datadesc}
\begin{datadesc}
{
YESEXPR
}
Return a regular expression that can be used with the regex
function to recognize a positive response to a yes/no question.
\[
Warning: the expression is in the syntax suitable for the
regex C library function, which might differ from the syntax
used in
\module
{
re
}\]
\end{datadesc}
\begin{datadesc}
{
NOEXPR
}
Return a regular expression that can be used with the regex(3)
function to recognize a negative response to a yes/no question.
\end{datadesc}
\begin{datadesc}
{
CRNCYSTR
}
Return the currency symbol, preceded by "-" if the symbol should
appear before the value, "+" if the symbol should appear after the
value, or "." if the symbol should replace the radix character.
\end{datadesc}
\begin{datadesc}
{
ERA
}
The return value represents the era used in the current locale.
Most locales do not define this value. An example of a locale which
does define this value is the Japanese one. In Japan, the traditional
representation of dates includes the name of the era corresponding to
the then-emperor's reign.
Normally it should not be necessary to use this value directly.
Specifying the
\code
{
E
}
modifier in their format strings causes the
\function
{
strftime
}
function to use this information. The format of the
returned string is not specified, and therefore you should not assume
knowledge of it on different systems.
\end{datadesc}
\begin{datadesc}
{
ERA
_
YEAR
}
The return value gives the year in the relevant era of the locale.
\end{datadesc}
\begin{datadesc}
{
ERA
_
D
_
T
_
FMT
}
This return value can be used as a format string for
\function
{
strftime
}
to represent dates and times in a locale-specific
era-based way.
\end{datadesc}
\begin{datadesc}
{
ERA
_
D
_
FMT
}
This return value can be used as a format string for
\function
{
strftime
}
to represent time in a locale-specific era-based
way.
\end{datadesc}
\begin{datadesc}
{
ALT
_
DIGITS
}
The return value is a representation of up to 100 values used to
represent the values 0 to 99.
\end{datadesc}
Example:
\begin{verbatim}
...
...
Lib/encodings/aliases.py
Dosyayı görüntüle @
9b75dca1
...
...
@@ -31,6 +31,8 @@ aliases = {
# ASCII
'us_ascii'
:
'ascii'
,
'ansi_x3.4_1968'
:
'ascii'
,
# used on Linux
'646'
:
'ascii'
,
# used on Solaris
# EBCDIC
'ebcdic_cp_us'
:
'cp037'
,
...
...
Modules/_localemodule.c
Dosyayı görüntüle @
9b75dca1
...
...
@@ -17,6 +17,10 @@ This software comes with no warranty. Use at your own risk.
#include <string.h>
#include <ctype.h>
#ifdef HAVE_LANGINFO_H
#include <langinfo.h>
#endif
#if defined(MS_WIN32)
#define WINDOWS_LEAN_AND_MEAN
#include <windows.h>
...
...
@@ -391,6 +395,23 @@ PyLocale_getdefaultlocale(PyObject* self, PyObject* args)
}
#endif
#ifdef HAVE_LANGINFO_H
static
char
nl_langinfo__doc__
[]
=
"nl_langinfo(key) -> string
\n
"
"Return the value for the locale information associated with key."
;
static
PyObject
*
PyLocale_nl_langinfo
(
PyObject
*
self
,
PyObject
*
args
)
{
int
item
;
if
(
!
PyArg_ParseTuple
(
args
,
"i:nl_langinfo"
,
&
item
))
return
NULL
;
return
PyString_FromString
(
nl_langinfo
(
item
));
}
#endif
static
struct
PyMethodDef
PyLocale_Methods
[]
=
{
{
"setlocale"
,
(
PyCFunction
)
PyLocale_setlocale
,
METH_VARARGS
,
setlocale__doc__
},
...
...
@@ -403,6 +424,11 @@ static struct PyMethodDef PyLocale_Methods[] = {
#if defined(MS_WIN32) || defined(macintosh)
{
"_getdefaultlocale"
,
(
PyCFunction
)
PyLocale_getdefaultlocale
,
0
},
#endif
#ifdef HAVE_LANGINFO_H
{
"nl_langinfo"
,
(
PyCFunction
)
PyLocale_nl_langinfo
,
METH_VARARGS
,
nl_langinfo__doc__
},
#endif
{
NULL
,
NULL
}
};
...
...
@@ -455,4 +481,81 @@ init_locale(void)
x
=
PyString_FromString
(
locale__doc__
);
PyDict_SetItemString
(
d
,
"__doc__"
,
x
);
Py_XDECREF
(
x
);
#define ADDINT(X) PyModule_AddIntConstant(m, #X, X)
#ifdef HAVE_LANGINFO_H
/* These constants should exist on any langinfo implementation */
ADDINT
(
DAY_1
);
ADDINT
(
DAY_2
);
ADDINT
(
DAY_3
);
ADDINT
(
DAY_4
);
ADDINT
(
DAY_5
);
ADDINT
(
DAY_6
);
ADDINT
(
DAY_7
);
ADDINT
(
ABDAY_1
);
ADDINT
(
ABDAY_2
);
ADDINT
(
ABDAY_3
);
ADDINT
(
ABDAY_4
);
ADDINT
(
ABDAY_5
);
ADDINT
(
ABDAY_6
);
ADDINT
(
ABDAY_7
);
ADDINT
(
MON_1
);
ADDINT
(
MON_2
);
ADDINT
(
MON_3
);
ADDINT
(
MON_4
);
ADDINT
(
MON_5
);
ADDINT
(
MON_6
);
ADDINT
(
MON_7
);
ADDINT
(
MON_8
);
ADDINT
(
MON_9
);
ADDINT
(
MON_10
);
ADDINT
(
MON_11
);
ADDINT
(
MON_12
);
ADDINT
(
ABMON_1
);
ADDINT
(
ABMON_2
);
ADDINT
(
ABMON_3
);
ADDINT
(
ABMON_4
);
ADDINT
(
ABMON_5
);
ADDINT
(
ABMON_6
);
ADDINT
(
ABMON_7
);
ADDINT
(
ABMON_8
);
ADDINT
(
ABMON_9
);
ADDINT
(
ABMON_10
);
ADDINT
(
ABMON_11
);
ADDINT
(
ABMON_12
);
ADDINT
(
RADIXCHAR
);
ADDINT
(
THOUSEP
);
/* YESSTR and NOSTR are deprecated in glibc, since they are
a special case of message translation, which should be rather
done using gettext. So we don't expose it to Python in the
first place.
ADDINT(YESSTR);
ADDINT(NOSTR);
*/
ADDINT
(
CRNCYSTR
);
ADDINT
(
D_T_FMT
);
ADDINT
(
D_FMT
);
ADDINT
(
T_FMT
);
ADDINT
(
AM_STR
);
ADDINT
(
PM_STR
);
#ifdef CODESET
/* The following constants are available only with XPG4. */
ADDINT
(
CODESET
);
ADDINT
(
T_FMT_AMPM
);
ADDINT
(
ERA
);
ADDINT
(
ERA_D_FMT
);
ADDINT
(
ERA_D_T_FMT
);
ADDINT
(
ERA_T_FMT
);
ADDINT
(
ALT_DIGITS
);
ADDINT
(
YESEXPR
);
ADDINT
(
NOEXPR
);
ADDINT
(
_DATE_FMT
);
#endif
#endif
/* HAVE_LANGINFO_H */
}
configure
Dosyayı görüntüle @
9b75dca1
This diff is collapsed.
Click to expand it.
configure.in
Dosyayı görüntüle @
9b75dca1
...
...
@@ -413,7 +413,8 @@ dnl AC_MSG_RESULT($cpp_type)
# checks for header files
AC_HEADER_STDC
AC_CHECK_HEADERS(dlfcn.h fcntl.h limits.h locale.h ncurses.h poll.h pthread.h \
AC_CHECK_HEADERS(dlfcn.h fcntl.h limits.h langinfo.h locale.h \
ncurses.h poll.h pthread.h \
signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h termios.h \
sys/audioio.h sys/file.h sys/lock.h sys/modem.h db_185.h db.h \
sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \
...
...
pyconfig.h.in
Dosyayı görüntüle @
9b75dca1
...
...
@@ -590,6 +590,9 @@
/* Define if you have the <gdbm/ndbm.h> header file. */
#undef HAVE_GDBM_NDBM_H
/* Define if you have the <langinfo.h> header file. */
#undef HAVE_LANGINFO_H
/* Define if you have the <libutil.h> header file. */
#undef HAVE_LIBUTIL_H
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment