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.CompareTo Behaviour different between WIN10 & Linux #36177

Closed
Ninds opened this issue May 10, 2020 · 4 comments
Closed

String.CompareTo Behaviour different between WIN10 & Linux #36177

Ninds opened this issue May 10, 2020 · 4 comments

Comments

@Ninds
Copy link

Ninds commented May 10, 2020

Console.WriteLine("[".CompareTo("_"));
On Windows => -1
On Linux => 1

Linux :
.NET Core SDK (reflecting any global.json):
Version: 3.1.201
Commit: b1768b4ae7

Runtime Environment:
OS Name: debian
OS Version: 10
OS Platform: Linux
RID: debian.10-x64

Host (useful for support):
Version: 3.1.3
Commit: 4a9f85e9f8

Windows :
.NET Core SDK (reflecting any global.json):
Version: 3.1.201
Commit: b1768b4ae7

Runtime Environment:
OS Name: Windows
OS Version: 10.0.17134
OS Platform: Windows
RID: win10-x64

Host (useful for support):
Version: 3.1.3
Commit: 4a9f85e9f8

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-Meta untriaged New issue has not been triaged by the area owner labels May 10, 2020
@benaadams
Copy link
Member

Different culture between the two? Try using .CompareOrdinal

@ghost
Copy link

ghost commented May 10, 2020

Tagging subscribers to this area: @tarekgh, @safern, @krwq
Notify danmosemsft if you want to be subscribed.

@jkotas jkotas removed the area-Meta label May 10, 2020
@tarekgh tarekgh removed the untriaged New issue has not been triaged by the area owner label May 10, 2020
@tarekgh
Copy link
Member

tarekgh commented May 10, 2020

This is by design for the .NET as we depend on the underlying OS for globalization support. so it is expected to see some behavior differences when running on Windows against Linux. @benaadams suggestion to use ordinal comparison should help if this will be ok in your scenario.

In .NET Core 5.0, we have started to use the ICU library on Windows too. That means the behavior on Windows and Linux should be the same or very close. You may give it a try.

@tarekgh tarekgh closed this as completed May 10, 2020
@Ninds
Copy link
Author

Ninds commented May 17, 2020

Cheers. Tweaking the culture indeed yielded the required behaviour.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants