Merged revisions 63078 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
When forward porting this, I added _PyUnicode_InsertThousandsGrouping.
........
r63078 | eric.smith | 2008-05-11 15:52:48 -0400 (Sun, 11 May 2008) | 14 lines
Addresses issue 2802: 'n' formatting for integers.
Adds 'n' as a format specifier for integers, to mirror the same
specifier which is already available for floats. 'n' is the same as
'd', but inserts the current locale-specific thousands grouping.
I added this as a stringlib function, but it's only used by str type,
not unicode. This is because of an implementation detail in
unicode.format(), which does its own str->unicode conversion. But the
unicode version will be needed in 3.0, and it may be needed by other
code eventually in 2.6 (maybe decimal?), so I left it as a stringlib
implementation. As long as the unicode version isn't instantiated,
there's no overhead for this.
........
2008-05-11 18:00:57 -03:00
|
|
|
/* stringlib: locale related helpers implementation */
|
|
|
|
|
|
|
|
#ifndef STRINGLIB_LOCALEUTIL_H
|
|
|
|
#define STRINGLIB_LOCALEUTIL_H
|
|
|
|
|
|
|
|
#include <locale.h>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* _Py_InsertThousandsGrouping:
|
|
|
|
* @buffer: A pointer to the start of a string.
|
2008-06-23 22:06:47 -03:00
|
|
|
* @n_buffer: The length of the string.
|
|
|
|
* @n_digits: The number of digits in the string, in which we want
|
|
|
|
* to put the grouping chars.
|
Merged revisions 63078 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
When forward porting this, I added _PyUnicode_InsertThousandsGrouping.
........
r63078 | eric.smith | 2008-05-11 15:52:48 -0400 (Sun, 11 May 2008) | 14 lines
Addresses issue 2802: 'n' formatting for integers.
Adds 'n' as a format specifier for integers, to mirror the same
specifier which is already available for floats. 'n' is the same as
'd', but inserts the current locale-specific thousands grouping.
I added this as a stringlib function, but it's only used by str type,
not unicode. This is because of an implementation detail in
unicode.format(), which does its own str->unicode conversion. But the
unicode version will be needed in 3.0, and it may be needed by other
code eventually in 2.6 (maybe decimal?), so I left it as a stringlib
implementation. As long as the unicode version isn't instantiated,
there's no overhead for this.
........
2008-05-11 18:00:57 -03:00
|
|
|
* @buf_size: The maximum size of the buffer pointed to by buffer.
|
|
|
|
* @count: If non-NULL, points to a variable that will receive the
|
|
|
|
* number of characters we need to insert (and no formatting
|
|
|
|
* will actually occur).
|
|
|
|
* @append_zero_char: If non-zero, put a trailing zero at the end of
|
|
|
|
* of the resulting string, if and only if we modified the
|
|
|
|
* string.
|
2009-04-03 11:45:06 -03:00
|
|
|
* @grouping: see definition in localeconv().
|
|
|
|
* @thousands_sep: see definition in localeconv().
|
Merged revisions 63078 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
When forward porting this, I added _PyUnicode_InsertThousandsGrouping.
........
r63078 | eric.smith | 2008-05-11 15:52:48 -0400 (Sun, 11 May 2008) | 14 lines
Addresses issue 2802: 'n' formatting for integers.
Adds 'n' as a format specifier for integers, to mirror the same
specifier which is already available for floats. 'n' is the same as
'd', but inserts the current locale-specific thousands grouping.
I added this as a stringlib function, but it's only used by str type,
not unicode. This is because of an implementation detail in
unicode.format(), which does its own str->unicode conversion. But the
unicode version will be needed in 3.0, and it may be needed by other
code eventually in 2.6 (maybe decimal?), so I left it as a stringlib
implementation. As long as the unicode version isn't instantiated,
there's no overhead for this.
........
2008-05-11 18:00:57 -03:00
|
|
|
*
|
2009-04-03 11:45:06 -03:00
|
|
|
* Inserts thousand grouping characters (as defined by grouping and
|
|
|
|
* thousands_sep) into the string between buffer and buffer+n_digits.
|
|
|
|
* If count is non-NULL, don't do any formatting, just count the
|
|
|
|
* number of characters to insert. This is used by the caller to
|
2008-06-23 22:06:47 -03:00
|
|
|
* appropriately resize the buffer, if needed. If count is non-NULL,
|
|
|
|
* buffer can be NULL (it is not dereferenced at all in that case).
|
Merged revisions 63078 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
When forward porting this, I added _PyUnicode_InsertThousandsGrouping.
........
r63078 | eric.smith | 2008-05-11 15:52:48 -0400 (Sun, 11 May 2008) | 14 lines
Addresses issue 2802: 'n' formatting for integers.
Adds 'n' as a format specifier for integers, to mirror the same
specifier which is already available for floats. 'n' is the same as
'd', but inserts the current locale-specific thousands grouping.
I added this as a stringlib function, but it's only used by str type,
not unicode. This is because of an implementation detail in
unicode.format(), which does its own str->unicode conversion. But the
unicode version will be needed in 3.0, and it may be needed by other
code eventually in 2.6 (maybe decimal?), so I left it as a stringlib
implementation. As long as the unicode version isn't instantiated,
there's no overhead for this.
........
2008-05-11 18:00:57 -03:00
|
|
|
*
|
|
|
|
* Return value: 0 on error, else 1. Note that no error can occur if
|
|
|
|
* count is non-NULL.
|
|
|
|
*
|
|
|
|
* This name won't be used, the includer of this file should define
|
|
|
|
* it to be the actual function name, based on unicode or string.
|
|
|
|
**/
|
|
|
|
int
|
|
|
|
_Py_InsertThousandsGrouping(STRINGLIB_CHAR *buffer,
|
2009-04-03 11:45:06 -03:00
|
|
|
Py_ssize_t n_buffer,
|
|
|
|
Py_ssize_t n_digits,
|
|
|
|
Py_ssize_t buf_size,
|
|
|
|
Py_ssize_t *count,
|
|
|
|
int append_zero_char,
|
|
|
|
const char *grouping,
|
|
|
|
const char *thousands_sep)
|
Merged revisions 63078 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
When forward porting this, I added _PyUnicode_InsertThousandsGrouping.
........
r63078 | eric.smith | 2008-05-11 15:52:48 -0400 (Sun, 11 May 2008) | 14 lines
Addresses issue 2802: 'n' formatting for integers.
Adds 'n' as a format specifier for integers, to mirror the same
specifier which is already available for floats. 'n' is the same as
'd', but inserts the current locale-specific thousands grouping.
I added this as a stringlib function, but it's only used by str type,
not unicode. This is because of an implementation detail in
unicode.format(), which does its own str->unicode conversion. But the
unicode version will be needed in 3.0, and it may be needed by other
code eventually in 2.6 (maybe decimal?), so I left it as a stringlib
implementation. As long as the unicode version isn't instantiated,
there's no overhead for this.
........
2008-05-11 18:00:57 -03:00
|
|
|
{
|
2009-04-03 11:45:06 -03:00
|
|
|
Py_ssize_t thousands_sep_len = strlen(thousands_sep);
|
|
|
|
STRINGLIB_CHAR *pend = NULL; /* current end of buffer */
|
|
|
|
STRINGLIB_CHAR *pmax = NULL; /* max of buffer */
|
|
|
|
char current_grouping;
|
|
|
|
Py_ssize_t remaining = n_digits; /* Number of chars remaining to
|
|
|
|
be looked at */
|
Merged revisions 63078 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
When forward porting this, I added _PyUnicode_InsertThousandsGrouping.
........
r63078 | eric.smith | 2008-05-11 15:52:48 -0400 (Sun, 11 May 2008) | 14 lines
Addresses issue 2802: 'n' formatting for integers.
Adds 'n' as a format specifier for integers, to mirror the same
specifier which is already available for floats. 'n' is the same as
'd', but inserts the current locale-specific thousands grouping.
I added this as a stringlib function, but it's only used by str type,
not unicode. This is because of an implementation detail in
unicode.format(), which does its own str->unicode conversion. But the
unicode version will be needed in 3.0, and it may be needed by other
code eventually in 2.6 (maybe decimal?), so I left it as a stringlib
implementation. As long as the unicode version isn't instantiated,
there's no overhead for this.
........
2008-05-11 18:00:57 -03:00
|
|
|
|
2009-04-03 11:45:06 -03:00
|
|
|
/* Initialize the character count, if we're just counting. */
|
|
|
|
if (count)
|
|
|
|
*count = 0;
|
|
|
|
else {
|
|
|
|
/* We're not just counting, we're modifying buffer */
|
|
|
|
pend = buffer + n_buffer;
|
|
|
|
pmax = buffer + buf_size;
|
|
|
|
}
|
Merged revisions 63078 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
When forward porting this, I added _PyUnicode_InsertThousandsGrouping.
........
r63078 | eric.smith | 2008-05-11 15:52:48 -0400 (Sun, 11 May 2008) | 14 lines
Addresses issue 2802: 'n' formatting for integers.
Adds 'n' as a format specifier for integers, to mirror the same
specifier which is already available for floats. 'n' is the same as
'd', but inserts the current locale-specific thousands grouping.
I added this as a stringlib function, but it's only used by str type,
not unicode. This is because of an implementation detail in
unicode.format(), which does its own str->unicode conversion. But the
unicode version will be needed in 3.0, and it may be needed by other
code eventually in 2.6 (maybe decimal?), so I left it as a stringlib
implementation. As long as the unicode version isn't instantiated,
there's no overhead for this.
........
2008-05-11 18:00:57 -03:00
|
|
|
|
2009-04-03 11:45:06 -03:00
|
|
|
/* Starting at the end and working right-to-left, keep track of
|
|
|
|
what grouping needs to be added and insert that. */
|
|
|
|
current_grouping = *grouping++;
|
Merged revisions 63078 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
When forward porting this, I added _PyUnicode_InsertThousandsGrouping.
........
r63078 | eric.smith | 2008-05-11 15:52:48 -0400 (Sun, 11 May 2008) | 14 lines
Addresses issue 2802: 'n' formatting for integers.
Adds 'n' as a format specifier for integers, to mirror the same
specifier which is already available for floats. 'n' is the same as
'd', but inserts the current locale-specific thousands grouping.
I added this as a stringlib function, but it's only used by str type,
not unicode. This is because of an implementation detail in
unicode.format(), which does its own str->unicode conversion. But the
unicode version will be needed in 3.0, and it may be needed by other
code eventually in 2.6 (maybe decimal?), so I left it as a stringlib
implementation. As long as the unicode version isn't instantiated,
there's no overhead for this.
........
2008-05-11 18:00:57 -03:00
|
|
|
|
2009-04-03 11:45:06 -03:00
|
|
|
/* If the first character is 0, perform no grouping at all. */
|
|
|
|
if (current_grouping == 0)
|
|
|
|
return 1;
|
Merged revisions 63078 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
When forward porting this, I added _PyUnicode_InsertThousandsGrouping.
........
r63078 | eric.smith | 2008-05-11 15:52:48 -0400 (Sun, 11 May 2008) | 14 lines
Addresses issue 2802: 'n' formatting for integers.
Adds 'n' as a format specifier for integers, to mirror the same
specifier which is already available for floats. 'n' is the same as
'd', but inserts the current locale-specific thousands grouping.
I added this as a stringlib function, but it's only used by str type,
not unicode. This is because of an implementation detail in
unicode.format(), which does its own str->unicode conversion. But the
unicode version will be needed in 3.0, and it may be needed by other
code eventually in 2.6 (maybe decimal?), so I left it as a stringlib
implementation. As long as the unicode version isn't instantiated,
there's no overhead for this.
........
2008-05-11 18:00:57 -03:00
|
|
|
|
2009-04-03 11:45:06 -03:00
|
|
|
while (remaining > current_grouping) {
|
|
|
|
/* Always leave buffer and pend valid at the end of this
|
|
|
|
loop, since we might leave with a return statement. */
|
Merged revisions 63078 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
When forward porting this, I added _PyUnicode_InsertThousandsGrouping.
........
r63078 | eric.smith | 2008-05-11 15:52:48 -0400 (Sun, 11 May 2008) | 14 lines
Addresses issue 2802: 'n' formatting for integers.
Adds 'n' as a format specifier for integers, to mirror the same
specifier which is already available for floats. 'n' is the same as
'd', but inserts the current locale-specific thousands grouping.
I added this as a stringlib function, but it's only used by str type,
not unicode. This is because of an implementation detail in
unicode.format(), which does its own str->unicode conversion. But the
unicode version will be needed in 3.0, and it may be needed by other
code eventually in 2.6 (maybe decimal?), so I left it as a stringlib
implementation. As long as the unicode version isn't instantiated,
there's no overhead for this.
........
2008-05-11 18:00:57 -03:00
|
|
|
|
2009-04-03 11:45:06 -03:00
|
|
|
remaining -= current_grouping;
|
|
|
|
if (count) {
|
|
|
|
/* We're only counting, not touching the memory. */
|
|
|
|
*count += thousands_sep_len;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Do the formatting. */
|
Merged revisions 63078 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
When forward porting this, I added _PyUnicode_InsertThousandsGrouping.
........
r63078 | eric.smith | 2008-05-11 15:52:48 -0400 (Sun, 11 May 2008) | 14 lines
Addresses issue 2802: 'n' formatting for integers.
Adds 'n' as a format specifier for integers, to mirror the same
specifier which is already available for floats. 'n' is the same as
'd', but inserts the current locale-specific thousands grouping.
I added this as a stringlib function, but it's only used by str type,
not unicode. This is because of an implementation detail in
unicode.format(), which does its own str->unicode conversion. But the
unicode version will be needed in 3.0, and it may be needed by other
code eventually in 2.6 (maybe decimal?), so I left it as a stringlib
implementation. As long as the unicode version isn't instantiated,
there's no overhead for this.
........
2008-05-11 18:00:57 -03:00
|
|
|
|
2009-04-03 11:45:06 -03:00
|
|
|
STRINGLIB_CHAR *plast = buffer + remaining;
|
2008-06-23 22:06:47 -03:00
|
|
|
|
2009-04-03 11:45:06 -03:00
|
|
|
/* Is there room to insert thousands_sep_len chars? */
|
|
|
|
if (pmax - pend < thousands_sep_len)
|
|
|
|
/* No room. */
|
|
|
|
return 0;
|
Merged revisions 63078 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
When forward porting this, I added _PyUnicode_InsertThousandsGrouping.
........
r63078 | eric.smith | 2008-05-11 15:52:48 -0400 (Sun, 11 May 2008) | 14 lines
Addresses issue 2802: 'n' formatting for integers.
Adds 'n' as a format specifier for integers, to mirror the same
specifier which is already available for floats. 'n' is the same as
'd', but inserts the current locale-specific thousands grouping.
I added this as a stringlib function, but it's only used by str type,
not unicode. This is because of an implementation detail in
unicode.format(), which does its own str->unicode conversion. But the
unicode version will be needed in 3.0, and it may be needed by other
code eventually in 2.6 (maybe decimal?), so I left it as a stringlib
implementation. As long as the unicode version isn't instantiated,
there's no overhead for this.
........
2008-05-11 18:00:57 -03:00
|
|
|
|
2009-04-03 11:45:06 -03:00
|
|
|
/* Move the rest of the string down. */
|
|
|
|
memmove(plast + thousands_sep_len,
|
|
|
|
plast,
|
|
|
|
(pend - plast) * sizeof(STRINGLIB_CHAR));
|
|
|
|
/* Copy the thousands_sep chars into the buffer. */
|
Merged revisions 63078 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
When forward porting this, I added _PyUnicode_InsertThousandsGrouping.
........
r63078 | eric.smith | 2008-05-11 15:52:48 -0400 (Sun, 11 May 2008) | 14 lines
Addresses issue 2802: 'n' formatting for integers.
Adds 'n' as a format specifier for integers, to mirror the same
specifier which is already available for floats. 'n' is the same as
'd', but inserts the current locale-specific thousands grouping.
I added this as a stringlib function, but it's only used by str type,
not unicode. This is because of an implementation detail in
unicode.format(), which does its own str->unicode conversion. But the
unicode version will be needed in 3.0, and it may be needed by other
code eventually in 2.6 (maybe decimal?), so I left it as a stringlib
implementation. As long as the unicode version isn't instantiated,
there's no overhead for this.
........
2008-05-11 18:00:57 -03:00
|
|
|
#if STRINGLIB_IS_UNICODE
|
2009-04-03 11:45:06 -03:00
|
|
|
/* Convert from the char's of the thousands_sep from
|
|
|
|
the locale into unicode. */
|
|
|
|
{
|
|
|
|
Py_ssize_t i;
|
|
|
|
for (i = 0; i < thousands_sep_len; ++i)
|
|
|
|
plast[i] = thousands_sep[i];
|
|
|
|
}
|
Merged revisions 63078 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
When forward porting this, I added _PyUnicode_InsertThousandsGrouping.
........
r63078 | eric.smith | 2008-05-11 15:52:48 -0400 (Sun, 11 May 2008) | 14 lines
Addresses issue 2802: 'n' formatting for integers.
Adds 'n' as a format specifier for integers, to mirror the same
specifier which is already available for floats. 'n' is the same as
'd', but inserts the current locale-specific thousands grouping.
I added this as a stringlib function, but it's only used by str type,
not unicode. This is because of an implementation detail in
unicode.format(), which does its own str->unicode conversion. But the
unicode version will be needed in 3.0, and it may be needed by other
code eventually in 2.6 (maybe decimal?), so I left it as a stringlib
implementation. As long as the unicode version isn't instantiated,
there's no overhead for this.
........
2008-05-11 18:00:57 -03:00
|
|
|
#else
|
2009-04-03 11:45:06 -03:00
|
|
|
/* No conversion, just memcpy the thousands_sep. */
|
|
|
|
memcpy(plast, thousands_sep, thousands_sep_len);
|
Merged revisions 63078 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
When forward porting this, I added _PyUnicode_InsertThousandsGrouping.
........
r63078 | eric.smith | 2008-05-11 15:52:48 -0400 (Sun, 11 May 2008) | 14 lines
Addresses issue 2802: 'n' formatting for integers.
Adds 'n' as a format specifier for integers, to mirror the same
specifier which is already available for floats. 'n' is the same as
'd', but inserts the current locale-specific thousands grouping.
I added this as a stringlib function, but it's only used by str type,
not unicode. This is because of an implementation detail in
unicode.format(), which does its own str->unicode conversion. But the
unicode version will be needed in 3.0, and it may be needed by other
code eventually in 2.6 (maybe decimal?), so I left it as a stringlib
implementation. As long as the unicode version isn't instantiated,
there's no overhead for this.
........
2008-05-11 18:00:57 -03:00
|
|
|
#endif
|
2009-04-03 11:45:06 -03:00
|
|
|
}
|
Merged revisions 63078 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
When forward porting this, I added _PyUnicode_InsertThousandsGrouping.
........
r63078 | eric.smith | 2008-05-11 15:52:48 -0400 (Sun, 11 May 2008) | 14 lines
Addresses issue 2802: 'n' formatting for integers.
Adds 'n' as a format specifier for integers, to mirror the same
specifier which is already available for floats. 'n' is the same as
'd', but inserts the current locale-specific thousands grouping.
I added this as a stringlib function, but it's only used by str type,
not unicode. This is because of an implementation detail in
unicode.format(), which does its own str->unicode conversion. But the
unicode version will be needed in 3.0, and it may be needed by other
code eventually in 2.6 (maybe decimal?), so I left it as a stringlib
implementation. As long as the unicode version isn't instantiated,
there's no overhead for this.
........
2008-05-11 18:00:57 -03:00
|
|
|
|
2009-04-03 11:45:06 -03:00
|
|
|
/* Adjust end pointer. */
|
|
|
|
pend += thousands_sep_len;
|
Merged revisions 63078 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
When forward porting this, I added _PyUnicode_InsertThousandsGrouping.
........
r63078 | eric.smith | 2008-05-11 15:52:48 -0400 (Sun, 11 May 2008) | 14 lines
Addresses issue 2802: 'n' formatting for integers.
Adds 'n' as a format specifier for integers, to mirror the same
specifier which is already available for floats. 'n' is the same as
'd', but inserts the current locale-specific thousands grouping.
I added this as a stringlib function, but it's only used by str type,
not unicode. This is because of an implementation detail in
unicode.format(), which does its own str->unicode conversion. But the
unicode version will be needed in 3.0, and it may be needed by other
code eventually in 2.6 (maybe decimal?), so I left it as a stringlib
implementation. As long as the unicode version isn't instantiated,
there's no overhead for this.
........
2008-05-11 18:00:57 -03:00
|
|
|
|
2009-04-03 11:45:06 -03:00
|
|
|
/* Move to the next grouping character, unless we're
|
|
|
|
repeating (which is designated by a grouping of 0). */
|
|
|
|
if (*grouping != 0) {
|
|
|
|
current_grouping = *grouping++;
|
|
|
|
if (current_grouping == CHAR_MAX)
|
|
|
|
/* We're done. */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (append_zero_char) {
|
|
|
|
/* Append a zero character to mark the end of the string,
|
|
|
|
if there's room. */
|
|
|
|
if (pend - (buffer + remaining) < 1)
|
|
|
|
/* No room, error. */
|
|
|
|
return 0;
|
|
|
|
*pend = 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* _Py_InsertThousandsGroupingLocale:
|
|
|
|
* @buffer: A pointer to the start of a string.
|
|
|
|
* @n_buffer: The length of the string.
|
|
|
|
* @n_digits: The number of digits in the string, in which we want
|
|
|
|
* to put the grouping chars.
|
|
|
|
* @buf_size: The maximum size of the buffer pointed to by buffer.
|
|
|
|
* @count: If non-NULL, points to a variable that will receive the
|
|
|
|
* number of characters we need to insert (and no formatting
|
|
|
|
* will actually occur).
|
|
|
|
* @append_zero_char: If non-zero, put a trailing zero at the end of
|
|
|
|
* of the resulting string, if and only if we modified the
|
|
|
|
* string.
|
|
|
|
*
|
|
|
|
* Reads thee current locale and calls _Py_InsertThousandsGrouping().
|
|
|
|
**/
|
|
|
|
int
|
|
|
|
_Py_InsertThousandsGroupingLocale(STRINGLIB_CHAR *buffer,
|
|
|
|
Py_ssize_t n_buffer,
|
|
|
|
Py_ssize_t n_digits,
|
|
|
|
Py_ssize_t buf_size,
|
|
|
|
Py_ssize_t *count,
|
|
|
|
int append_zero_char)
|
|
|
|
{
|
|
|
|
struct lconv *locale_data = localeconv();
|
|
|
|
const char *grouping = locale_data->grouping;
|
|
|
|
const char *thousands_sep = locale_data->thousands_sep;
|
|
|
|
|
|
|
|
return _Py_InsertThousandsGrouping(buffer, n_buffer, n_digits,
|
|
|
|
buf_size, count,
|
|
|
|
append_zero_char, grouping,
|
|
|
|
thousands_sep);
|
Merged revisions 63078 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
When forward porting this, I added _PyUnicode_InsertThousandsGrouping.
........
r63078 | eric.smith | 2008-05-11 15:52:48 -0400 (Sun, 11 May 2008) | 14 lines
Addresses issue 2802: 'n' formatting for integers.
Adds 'n' as a format specifier for integers, to mirror the same
specifier which is already available for floats. 'n' is the same as
'd', but inserts the current locale-specific thousands grouping.
I added this as a stringlib function, but it's only used by str type,
not unicode. This is because of an implementation detail in
unicode.format(), which does its own str->unicode conversion. But the
unicode version will be needed in 3.0, and it may be needed by other
code eventually in 2.6 (maybe decimal?), so I left it as a stringlib
implementation. As long as the unicode version isn't instantiated,
there's no overhead for this.
........
2008-05-11 18:00:57 -03:00
|
|
|
}
|
|
|
|
#endif /* STRINGLIB_LOCALEUTIL_H */
|