Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
d1d653d8
Commit
d1d653d8
authored
Apr 02, 2020
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement the L specifier
parent
73c84374
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
12 deletions
+14
-12
doc/syntax.rst
doc/syntax.rst
+10
-10
include/fmt/format.h
include/fmt/format.h
+1
-0
test/format-test.cc
test/format-test.cc
+3
-2
No files found.
doc/syntax.rst
View file @
d1d653d8
...
...
@@ -81,8 +81,8 @@ The general form of a *standard format specifier* is:
sign: "+" | "-" | " "
width: `integer` | "{" `arg_id` "}"
precision: `integer` | "{" `arg_id` "}"
type: `int_type` | "a" | "A" | "c" | "e" | "E" | "f" | "F" | "g" | "G" | "p" | "s"
int_type: "b" | "B" | "d" | "
n" | "
o" | "x" | "X"
type: `int_type` | "a" | "A" | "c" | "e" | "E" | "f" | "F" | "g" | "G" | "
L" | "
p" | "s"
int_type: "b" | "B" | "d" | "o" | "x" | "X"
The *fill* character can be any Unicode code point other than ``'{'`` or
``'}'``. The presence of a fill character is signaled by the character following
...
...
@@ -143,7 +143,7 @@ conversions, trailing zeros are not removed from the result.
.. ifconfig:: False
The ``','`` option signals the use of a comma for a thousands separator.
For a locale aware separator, use the ``'
n
'`` integer presentation type
For a locale aware separator, use the ``'
L
'`` integer presentation type
instead.
*width* is a decimal integer defining the minimum field width. If not
...
...
@@ -214,9 +214,9 @@ The available integer presentation types are:
| | ``'#'`` option with this type adds the prefix ``"0X"`` |
| | to the output value. |
+---------+----------------------------------------------------------+
| ``'
n'`` | Number. This is the same as ``'d'``, except that it uses
|
| |
the current locale setting to insert the appropriate
|
| |
number separator characters.
|
| ``'
L'`` | Locale-specific format. This is the same as ``'d'``,
|
| |
except that it uses the current locale setting to insert
|
| |
the appropriate number separator characters.
|
+---------+----------------------------------------------------------+
| none | The same as ``'d'``. |
+---------+----------------------------------------------------------+
...
...
@@ -261,9 +261,9 @@ The available presentation types for floating-point values are:
| | ``'E'`` if the number gets too large. The |
| | representations of infinity and NaN are uppercased, too. |
+---------+----------------------------------------------------------+
| ``'
n'`` | Number. This is the same as ``'g'``, except that it uses
|
| |
the current locale setting to insert the appropriate
|
| |
number separator characters.
|
| ``'
L'`` | Locale-specific format. This is the same as ``'g'``,
|
| |
except that it uses the current locale setting to insert
|
| |
the appropriate number separator characters.
|
+---------+----------------------------------------------------------+
| none | Similar to ``'g'``, except that fixed-point notation, |
| | when used, has at least one digit past the decimal |
...
...
@@ -403,7 +403,7 @@ Using the comma as a thousands separator::
#include <fmt/locale.h>
auto s = fmt::format(std::locale("en_US.UTF-8"), "{:
n
}", 1234567890);
auto s = fmt::format(std::locale("en_US.UTF-8"), "{:
L
}", 1234567890);
// s == "1,234,567,890"
.. ifconfig:: False
...
...
include/fmt/format.h
View file @
d1d653d8
...
...
@@ -1236,6 +1236,7 @@ FMT_CONSTEXPR void handle_int_type_spec(char spec, Handler&& handler) {
handler
.
on_oct
();
break
;
case
'n'
:
case
'L'
:
handler
.
on_num
();
break
;
default:
...
...
test/format-test.cc
View file @
d1d653d8
...
...
@@ -1256,7 +1256,7 @@ TEST(FormatterTest, FormatShort) {
TEST
(
FormatterTest
,
FormatInt
)
{
EXPECT_THROW_MSG
(
format
(
"{0:v"
,
42
),
format_error
,
"missing '}' in format string"
);
check_unknown_types
(
42
,
"bBdoxXn"
,
"integer"
);
check_unknown_types
(
42
,
"bBdoxXn
L
"
,
"integer"
);
}
TEST
(
FormatterTest
,
FormatBin
)
{
...
...
@@ -1397,6 +1397,7 @@ TEST(FormatterTest, FormatOct) {
TEST
(
FormatterTest
,
FormatIntLocale
)
{
EXPECT_EQ
(
"1234"
,
format
(
"{:n}"
,
1234
));
EXPECT_EQ
(
"1234"
,
format
(
"{:L}"
,
1234
));
}
struct
ConvertibleToLongLong
{
...
...
@@ -1491,7 +1492,7 @@ TEST(FormatterTest, FormatLongDouble) {
}
TEST
(
FormatterTest
,
FormatChar
)
{
const
char
types
[]
=
"cbBdoxXn"
;
const
char
types
[]
=
"cbBdoxXn
L
"
;
check_unknown_types
(
'a'
,
types
,
"char"
);
EXPECT_EQ
(
"a"
,
format
(
"{0}"
,
'a'
));
EXPECT_EQ
(
"z"
,
format
(
"{0:c}"
,
'z'
));
...
...
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