Manatee.Json icon indicating copy to clipboard operation
Manatee.Json copied to clipboard

Replace invalid utf-32 characters with U+FFFD � REPLACEMENT CHARACTER (0xFFFD)

Open nikas-belogolov opened this issue 4 years ago • 1 comments

Describe the bug We need to replace invalid utf-32 characters with the Replacement Character

Expected behavior The expected behavior is to replace invalid utf-32 characters with the Replacement Character

Additional context The Replacement Character is used to replace invalid characters. Golang do that in their JSON standard library

Maybe something like this: int.TryParse(source.Substring(index, 4), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out int hex) if (!hex.IsValidUtf32CodePoint()) hex = 0xFFFD;

https://github.com/gregsdennis/Manatee.Json/blob/b80a961bfa1214cb7744a44f04897aeb21ae26e2/Manatee.Json/Parsing/StringParser.cs#L220

nikas-belogolov avatar Feb 14 '21 13:02 nikas-belogolov

Thanks for the suggestion, but I'm not sure that this behavior is in line with JSON.

Lastly, this project is no longer active.

gregsdennis avatar Feb 15 '21 00:02 gregsdennis