Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
json
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
json
Commits
44a8e9bf
Commit
44a8e9bf
authored
Apr 03, 2016
by
Niels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
locale-independent dump
parent
9c233be5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
json.hpp
src/json.hpp
+10
-0
json.hpp.re2c
src/json.hpp.re2c
+10
-0
No files found.
src/json.hpp
View file @
44a8e9bf
...
...
@@ -2148,6 +2148,7 @@ class basic_json
string_t
dump
(
const
int
indent
=
-
1
)
const
{
std
::
stringstream
ss
;
ss
.
imbue
(
std
::
locale
(
"C"
));
if
(
indent
>=
0
)
{
...
...
@@ -5653,11 +5654,20 @@ class basic_json
const
bool
pretty_print
=
(
o
.
width
()
>
0
);
const
auto
indentation
=
(
pretty_print
?
o
.
width
()
:
0
);
// save locale of o
auto
old_locale
=
o
.
getloc
();
// set locale of o to "C"
o
.
imbue
(
std
::
locale
(
"C"
));
// reset width to 0 for subsequent calls to this stream
o
.
width
(
0
);
// do the actual serialization
j
.
dump
(
o
,
pretty_print
,
static_cast
<
unsigned
int
>
(
indentation
));
// reset locale
o
.
imbue
(
old_locale
);
return
o
;
}
...
...
src/json.hpp.re2c
View file @
44a8e9bf
...
...
@@ -2148,6 +2148,7 @@ class basic_json
string_t dump(const int indent = -1) const
{
std::stringstream ss;
ss.imbue(std::locale("C"));
if (indent >= 0)
{
...
...
@@ -5653,11 +5654,20 @@ class basic_json
const bool pretty_print = (o.width() > 0);
const auto indentation = (pretty_print ? o.width() : 0);
// save locale of o
auto old_locale = o.getloc();
// set locale of o to "C"
o.imbue(std::locale("C"));
// reset width to 0 for subsequent calls to this stream
o.width(0);
// do the actual serialization
j.dump(o, pretty_print, static_cast<unsigned int>(indentation));
// reset locale
o.imbue(old_locale);
return o;
}
...
...
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