-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #11: Allow for properly-formed UTF-8 strings to pass through to…
… the output ostream.
- Loading branch information
Showing
6 changed files
with
29 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,8 +21,7 @@ | |
namespace jsonv | ||
{ | ||
|
||
/** An encoder is responsible for writing values to some form of output. | ||
**/ | ||
/** An encoder is responsible for writing values to some form of output. **/ | ||
class JSONV_PUBLIC encoder | ||
{ | ||
public: | ||
|
@@ -148,6 +147,17 @@ class JSONV_PUBLIC ostream_encoder : | |
|
||
virtual ~ostream_encoder() noexcept; | ||
|
||
/** If set to true (the default), then all non-ASCII characters in strings will be replaced with their numeric | ||
* encodings. Since JSON allows for encoded text to be contained in a document, this is inefficient if you have | ||
* many non-ASCII characters. If you know that your decoding side can properly handle UTF-8 encoding, then you | ||
* should turn this on. | ||
* | ||
* \note | ||
* This functionality cannot be used to passthrough malformed UTF-8 encoded strings. If a given string is invalid | ||
* UTF-8, it will still get replaced with a numeric encoding. | ||
**/ | ||
void ensure_ascii(bool value); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
tgockel
Author
Owner
|
||
|
||
protected: | ||
virtual void write_null() override; | ||
|
||
|
@@ -179,6 +189,7 @@ class JSONV_PUBLIC ostream_encoder : | |
|
||
private: | ||
std::ostream& _output; | ||
bool _ensure_ascii; | ||
}; | ||
|
||
/** Like \c ostream_encoder, but pretty prints output to an \c std::ostream. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Method ensure_ascii is not implemented yet. Is it by design ?