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 comparison regression bug #96205

Closed
clement911 opened this issue Dec 20, 2023 · 6 comments
Closed

String comparison regression bug #96205

clement911 opened this issue Dec 20, 2023 · 6 comments

Comments

@clement911
Copy link

clement911 commented Dec 20, 2023

Description

The String comparison logic returns incorrect result for some string.

Reproduction Steps

using System;
using System.Globalization;

public class Program
{
   public static void Main()
   {
       Console.WriteLine(new CultureInfo("en-US").CompareInfo.Compare("ʻ", "", CompareOptions.IgnoreNonSpace));
   }
}

Expected behavior

Console prints 0

Actual behavior

Console prints 1

Regression?

It's a regression.
It works fine in .NET framework 4.7.2 so it appears the bug is limited to .NET core

Known Workarounds

None that I'm aware of.

Configuration

.NET 8 Windows x64

Other information

This seems to be a regression. It works in .NET framework but not .NET core

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Dec 20, 2023
@ghost
Copy link

ghost commented Dec 20, 2023

Tagging subscribers to this area: @DavoudEshtehari, @David-Engel, @JRahnama
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

The SqlString class comparison logic returns incorrect result for some string.

Reproduction Steps

using System;
using System.Linq;
using System.Data.SqlTypes;

public class Program
{
	public static void Main()
	{
		 var sqlCompareOptions = SqlCompareOptions.IgnoreCase | SqlCompareOptions.IgnoreNonSpace | SqlCompareOptions.IgnoreKanaType | SqlCompareOptions.IgnoreWidth;
 		 var res = new SqlString("ʻ", 1033, sqlCompareOptions) == new SqlString("", 1033, sqlCompareOptions);
		 Console.WriteLine(res);
	}
}

Expected behavior

Console prints True

Actual behavior

Console prints False

Regression?

It's a regression.
It works fine in .NET framework 4.7.2 so it appears the bug is limited to .NET core

Known Workarounds

None that I'm aware of.

Configuration

.NET 8 Windows x64

Other information

This seems to be a regression. It works in .NET framework but not .NET core

Author: clement911
Assignees: -
Labels:

area-System.Data.SqlClient, untriaged

Milestone: -

@clement911 clement911 changed the title SqlString comparison bug SqlString comparison regression bug Dec 20, 2023
@clement911 clement911 changed the title SqlString comparison regression bug String comparison regression bug Dec 20, 2023
@ghost
Copy link

ghost commented Dec 20, 2023

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

Issue Details

Description

The String comparison logic returns incorrect result for some string.

Reproduction Steps

using System;
using System.Globalization;

public class Program
{
   public static void Main()
   {
       Console.WriteLine(new CultureInfo("en-US").CompareInfo.Compare("ʻ", "", CompareOptions.IgnoreNonSpace));
   }
}

Expected behavior

Console prints 0

Actual behavior

Console prints 1

Regression?

It's a regression.
It works fine in .NET framework 4.7.2 so it appears the bug is limited to .NET core

Known Workarounds

None that I'm aware of.

Configuration

.NET 8 Windows x64

Other information

This seems to be a regression. It works in .NET framework but not .NET core

Author: clement911
Assignees: -
Labels:

area-System.Globalization, untriaged

Milestone: -

@huoyaoyuan
Copy link
Member

There is wide globalization change between .NET Framework and .NET Core. .NET Framework uses Windows NLS while .NET Core uses ICU by default. See https://learn.microsoft.com/dotnet/core/extensions/globalization-icu .

With that said, this may be a bug of CompareOptions.IgnoreNonSpace handling in .NET Core.

@clement911
Copy link
Author

@huoyaoyuan the doc says that ICU is used from .NET 5 onwards but I can reproduce the issue even with .NET Core 3.1 so it might not be related to the ICU change

@clement911
Copy link
Author

Actually sorry, I cannot reproduce with .NET Core 3.1
We came across this bug because it makes SqlString comparison not consistent with sql server's behavior.

@tarekgh
Copy link
Member

tarekgh commented Dec 24, 2023

Closing this as per replies. Apps want to get the old behavior can use use nls instead of icu. We don't recommend it though as in the future this will be legacy obsolete behavior.

@tarekgh tarekgh closed this as completed Dec 24, 2023
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Dec 24, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2024
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

3 participants