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
7214243d
Commit
7214243d
authored
Jun 28, 2016
by
Niels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reset locale (for #272)
parent
420659f1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
3 deletions
+15
-3
json.hpp
src/json.hpp
+4
-1
json.hpp.re2c
src/json.hpp.re2c
+4
-1
unit.cpp
test/src/unit.cpp
+7
-1
No files found.
src/json.hpp
View file @
7214243d
...
@@ -5658,10 +5658,13 @@ class basic_json
...
@@ -5658,10 +5658,13 @@ class basic_json
// reset width to 0 for subsequent calls to this stream
// reset width to 0 for subsequent calls to this stream
o
.
width
(
0
);
o
.
width
(
0
);
// fix locale problems
// fix locale problems
o
.
imbue
(
std
::
locale
(
std
::
locale
(),
new
DecimalSeparator
));
auto
old_locale
=
o
.
imbue
(
std
::
locale
(
std
::
locale
(),
new
DecimalSeparator
));
// do the actual serialization
// do the actual serialization
j
.
dump
(
o
,
pretty_print
,
static_cast
<
unsigned
int
>
(
indentation
));
j
.
dump
(
o
,
pretty_print
,
static_cast
<
unsigned
int
>
(
indentation
));
// reset locale
o
.
imbue
(
old_locale
);
return
o
;
return
o
;
}
}
...
...
src/json.hpp.re2c
View file @
7214243d
...
@@ -5658,10 +5658,13 @@ class basic_json
...
@@ -5658,10 +5658,13 @@ class basic_json
// reset width to 0 for subsequent calls to this stream
// reset width to 0 for subsequent calls to this stream
o.width(0);
o.width(0);
// fix locale problems
// fix locale problems
o.imbue(std::locale(std::locale(), new DecimalSeparator));
auto old_locale =
o.imbue(std::locale(std::locale(), new DecimalSeparator));
// do the actual serialization
// do the actual serialization
j.dump(o, pretty_print, static_cast<unsigned int>(indentation));
j.dump(o, pretty_print, static_cast<unsigned int>(indentation));
// reset locale
o.imbue(old_locale);
return o;
return o;
}
}
...
...
test/src/unit.cpp
View file @
7214243d
...
@@ -14079,9 +14079,15 @@ TEST_CASE("regression tests")
...
@@ -14079,9 +14079,15 @@ TEST_CASE("regression tests")
CHECK
(
j1a
.
dump
()
==
"23.42"
);
CHECK
(
j1a
.
dump
()
==
"23.42"
);
CHECK
(
j1b
.
dump
()
==
"23.42"
);
CHECK
(
j1b
.
dump
()
==
"23.42"
);
// check if locale is properly reset
std
::
stringstream
ss
;
std
::
stringstream
ss
;
ss
.
imbue
(
std
::
locale
(
std
::
locale
(),
new
CommaDecimalSeparator
));
ss
<<
47.11
;
CHECK
(
ss
.
str
()
==
"47,11"
);
ss
<<
j1a
;
ss
<<
j1a
;
CHECK
(
ss
.
str
()
==
"23.42"
);
CHECK
(
ss
.
str
()
==
"47,1123.42"
);
ss
<<
47.11
;
CHECK
(
ss
.
str
()
==
"47,1123.4247,11"
);
CHECK
(
j2a
.
dump
()
==
"23.42"
);
CHECK
(
j2a
.
dump
()
==
"23.42"
);
//issue #230
//issue #230
...
...
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