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") Zero #54951

Closed
my522cn opened this issue Jun 30, 2021 · 5 comments
Closed

String.IndexOf("\0") Zero #54951

my522cn opened this issue Jun 30, 2021 · 5 comments
Labels
area-System.Globalization untriaged New issue has not been triaged by the area owner

Comments

@my522cn
Copy link

my522cn commented Jun 30, 2021

Description

Before dotnet5, below code d and e are both 9. But in dotnet5, e is 0. I think it is a bug.

string a = "FT4EVT0DA\0\0\0?\u007f\0\0";
var d = a.IndexOf('\0');
var e = a.IndexOf("\0");

Configuration

  • Which version of .NET is the code running on?
  • 5.0
  • What OS and version, and what distro if applicable?
  • Win10 20H2
  • What is the architecture (x64, x86, ARM, ARM64)?
  • x64

Regression?

Other information

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Jun 30, 2021
@teo-tsirpanis
Copy link
Contributor

Hello, .NET 5 started using the ICU globalization libraries on Windows 10 1903 or newer for consistency with other operating systems. This change has unavoidably brought some breaking behavioral changes like this one.

In your case however, if you are simply looking for null characters in a string, an ordinal search would be ideal for you. IndexOf with a character always makes ordinal searches, and you can perform an ordinal search on a string like this:

var e = a.IndexOf("\0", StringComparison.Ordinal);

@ghost
Copy link

ghost commented Jun 30, 2021

Tagging subscribers to this area: @dotnet/area-system-runtime
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

Before dotnet5, below code d and e are both 9. But in dotnet5, e is 0. I think it is a bug.

string a = "FT4EVT0DA\0\0\0?\u007f\0\0";
var d = a.IndexOf('\0');
var e = a.IndexOf("\0");

Configuration

  • Which version of .NET is the code running on?
  • 5.0
  • What OS and version, and what distro if applicable?
  • Win10 20H2
  • What is the architecture (x64, x86, ARM, ARM64)?
  • x64

Regression?

Other information

Author: my522cn
Assignees: -
Labels:

area-System.Runtime, untriaged

Milestone: -

@ghost
Copy link

ghost commented Jun 30, 2021

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

Issue Details

Description

Before dotnet5, below code d and e are both 9. But in dotnet5, e is 0. I think it is a bug.

string a = "FT4EVT0DA\0\0\0?\u007f\0\0";
var d = a.IndexOf('\0');
var e = a.IndexOf("\0");

Configuration

  • Which version of .NET is the code running on?
  • 5.0
  • What OS and version, and what distro if applicable?
  • Win10 20H2
  • What is the architecture (x64, x86, ARM, ARM64)?
  • x64

Regression?

Other information

Author: my522cn
Assignees: -
Labels:

area-System.Globalization, area-System.Runtime, untriaged

Milestone: -

@tarekgh
Copy link
Member

tarekgh commented Jun 30, 2021

@my522cn please look at the issue #46569 for more details. I am closing this issue but feel free to send any question and we'll be happy to help with.

@tarekgh tarekgh closed this as completed Jun 30, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Jul 30, 2021
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

5 participants