🚧 first implementation for keep

This commit is contained in:
Niels Lohmann
2024-12-20 15:40:20 +01:00
parent a27a5b5442
commit a2d828c204
10 changed files with 54 additions and 25 deletions

View File

@@ -25,10 +25,11 @@ and `ensure_ascii` parameters.
result consists of ASCII characters only.
`error_handler` (in)
: how to react on decoding errors; there are three possible values (see [`error_handler_t`](error_handler_t.md):
`strict` (throws and exception in case a decoding error occurs; default), `replace` (replace invalid UTF-8 sequences
with U+FFFD), and `ignore` (ignore invalid UTF-8 sequences during serialization; all bytes are copied to the output
unchanged)).
: how to react on decoding errors; there are three possible values (see [`error_handler_t`](error_handler_t.md)):
: - `strict`: throws a [`type_error`](../../home/exceptions.md#type-errors) exception in case a decoding error occurs (this is the default),
- `replace`: replace invalid UTF-8 sequences with U+FFFD (<28> REPLACEMENT CHARACTER),
- `ignore`: ignore invalid UTF-8 sequences during serialization, and
- `keep`: keep invalid UTF-8 sequences during serialization; all bytes are copied to the output unchanged
## Return value
@@ -77,3 +78,4 @@ Binary values are serialized as object containing two keys:
- Indentation character `indent_char`, option `ensure_ascii` and exceptions added in version 3.0.0.
- Error handlers added in version 3.4.0.
- Serialization of binary values added in version 3.8.0.
- Added support for error handler value `keep` in version ???.

View File

@@ -12,13 +12,16 @@ This enumeration is used in the [`dump`](dump.md) function to choose how to trea
`basic_json` value. Three values are differentiated:
strict
: throw a `type_error` exception in case of invalid UTF-8
: throw a [`type_error`](../../home/exceptions.md#type-errors) exception in case of invalid UTF-8
replace
: replace invalid UTF-8 sequences with U+FFFD (<28> REPLACEMENT CHARACTER)
ignore
: ignore invalid UTF-8 sequences; all bytes are copied to the output unchanged
: ignore invalid UTF-8 sequences
keep
: keep invalid UTF-8 sequences; all bytes are copied to the output unchanged
## Examples
@@ -40,3 +43,4 @@ ignore
## Version history
- Added in version 3.4.0.
- Added value `keep` in version ???.