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

String.IndexOf("\0") returns always 0 in .NET 5.0 #47145

Closed
ghost opened this issue Jan 18, 2021 · 3 comments
Closed

String.IndexOf("\0") returns always 0 in .NET 5.0 #47145

ghost opened this issue Jan 18, 2021 · 3 comments
Labels
area-System.Globalization untriaged New issue has not been triaged by the area owner

Comments

@ghost
Copy link

ghost commented Jan 18, 2021

Here's a small example code to reproduce the issue:

byte[] buf = { (byte)'A', (byte)'B', (byte)'C', (byte)'\0' };
string s = Encoding.ASCII.GetString(buf);
Console.WriteLine(s.IndexOf("\0")); /* outputs 0 for .NET 5 and 3 for .NET Core 3.1 */
Console.WriteLine(s.IndexOf('\0')); /* outputs 3 for .NET 5 and 3 for .NET Core 3.1 */

Ok, it doesn't make much sense to search for "\0" instead of '\0', but the results differ from .NET Core 3.1.

@mairaw mairaw transferred this issue from dotnet/core Jan 19, 2021
@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.Globalization untriaged New issue has not been triaged by the area owner labels Jan 19, 2021
@ghost
Copy link

ghost commented Jan 19, 2021

Tagging subscribers to this area: @tarekgh, @safern, @krwq
See info in area-owners.md if you want to be subscribed.

Issue Details

Here's a small example code to reproduce the issue:

byte[] buf = { (byte)'A', (byte)'B', (byte)'C', (byte)'\0' };
string s = Encoding.ASCII.GetString(buf);
Console.WriteLine(s.IndexOf("\0")); /* outputs 0 for .NET 5 and 3 for .NET Core 3.1 */
Console.WriteLine(s.IndexOf('\0')); /* outputs 3 for .NET 5 and 3 for .NET Core 3.1 */

Ok, it doesn't make much sense to search for "\0" instead of '\0', but the results differ from .NET Core 3.1.

Author: fn2020
Assignees: -
Labels:

area-System.Globalization, untriaged

Milestone: -

@huoyaoyuan
Copy link
Member

duplicate of #46569

@ghost
Copy link
Author

ghost commented Jan 19, 2021

@ghost ghost closed this as completed Jan 19, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Feb 18, 2021
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Globalization untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

No branches or pull requests

1 participant