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

DecoderNLS.Convert doesn't always out the correct value for 'completed' #13585

Closed
GrabYourPitchforks opened this issue Oct 15, 2019 · 5 comments · Fixed by dotnet/coreclr#27210
Assignees
Milestone

Comments

@GrabYourPitchforks
Copy link
Member

This is pretty much the same issue as https://github.com/dotnet/coreclr/issues/23020, but we forgot to apply the same fix to the DecoderNLS class.

Repro code:

Encoder encoder = Encoding.UTF8.GetEncoder();
encoder.Convert(new char[] { '\ud800' }, 0, 1, new byte[0], 0, 0, flush: false, out int charsUsed, out int bytesUsed, out bool completed);
Console.WriteLine(charsUsed);
Console.WriteLine(bytesUsed);
Console.WriteLine(completed);
Console.WriteLine();

Decoder decoder = Encoding.UTF8.GetDecoder();
decoder.Convert(new byte[] { 0xF0 }, 0, 1, new char[0], 0, 0, flush: false, out bytesUsed, out charsUsed, out completed);
Console.WriteLine(bytesUsed);
Console.WriteLine(charsUsed);
Console.WriteLine(completed);

Output on .NET Framework 4.8:

1
0
True     <-- this is incorrect

1
0
True     <-- this is incorrect

Output on .NET Core 3.0:

1
0
False    <-- this is correct

1
0
True     <-- this is still incorrect

/cc @tarekgh as FYI

@GrabYourPitchforks GrabYourPitchforks self-assigned this Oct 15, 2019
@tarekgh
Copy link
Member

tarekgh commented Oct 15, 2019

@GrabYourPitchforks do you think this could be important enough to port to 3.1?

@GrabYourPitchforks
Copy link
Member Author

Unsure. It's affecting my ability to create unit tests for https://github.com/dotnet/corefx/issues/41326. But I seem to be the only person in the world running into these issues. :)

@tarekgh
Copy link
Member

tarekgh commented Oct 15, 2019

@GrabYourPitchforks this make it very important to port it then :-)

@GrabYourPitchforks
Copy link
Member Author

Eh, sure. The worst shiproom can say is "no". :)

@ahsonkhan
Copy link
Member

Re-opening until it's fixed in 3.1 (or we change the milestone).

@ahsonkhan ahsonkhan reopened this Oct 16, 2019
@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@msftgits msftgits added this to the 3.1 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants