Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove escaped solidus from writer #193

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions SpanJson/JsonWriter.Utf16.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public void WriteUtf16Char(char value)
}

WriteUtf16DoubleQuote();
if (value < 0x20 || value == JsonUtf16Constant.DoubleQuote || value == JsonUtf16Constant.Solidus || value == JsonUtf16Constant.ReverseSolidus)
if (value < 0x20 || value == JsonUtf16Constant.DoubleQuote || value == JsonUtf16Constant.ReverseSolidus)
{
WriteEscapedUtf16CharInternal(value);
}
Expand Down Expand Up @@ -405,7 +405,7 @@ public void WriteUtf16String(in ReadOnlySpan<char> value)
for (var i = 0; i < value.Length; i++)
{
ref readonly var c = ref value[i];
if (c < 0x20 || c == JsonUtf16Constant.DoubleQuote || c == JsonUtf16Constant.Solidus || c == JsonUtf16Constant.ReverseSolidus)
if (c < 0x20 || c == JsonUtf16Constant.DoubleQuote || c == JsonUtf16Constant.ReverseSolidus)
{
WriteEscapedUtf16CharInternal(c);
var remaining = 5 + value.Length - i; // make sure that all characters and an extra 5 for a full escape still fit
Expand Down
4 changes: 2 additions & 2 deletions SpanJson/JsonWriter.Utf8.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public void WriteUtf8String(in ReadOnlySpan<char> value)
while (index < value.Length)
{
ref readonly var c = ref value[index];
if (c < 0x20 || c == JsonUtf8Constant.DoubleQuote || c == JsonUtf8Constant.Solidus || c == JsonUtf8Constant.ReverseSolidus)
if (c < 0x20 || c == JsonUtf8Constant.DoubleQuote || c == JsonUtf8Constant.ReverseSolidus)
{
// changed extraBytes to 0 and post grow the buffer, if required, by atleast 7, the previous code failed in some rare combinations of content and buffer size
// instead of checking the buffer size here to get atleast the 7 extra bytes in, we do it after writing the initial buffer (which works due to Grow above)
Expand Down Expand Up @@ -437,7 +437,7 @@ private void WriteEscapedUtf8CharInternal(char value)
private void WriteUtf8CharInternal(char value)
{
ref var pos = ref _pos;
if (value < 0x20 || value == JsonUtf8Constant.DoubleQuote || value == JsonUtf8Constant.Solidus || value == JsonUtf8Constant.ReverseSolidus)
if (value < 0x20 || value == JsonUtf8Constant.DoubleQuote || value == JsonUtf8Constant.ReverseSolidus)
{
WriteEscapedUtf8CharInternal(value);
}
Expand Down