Skip to content

Remove dependencies on culture LCID inside SqlString codebase #111395

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

Open
matouskozak opened this issue Jan 14, 2025 · 0 comments
Open

Remove dependencies on culture LCID inside SqlString codebase #111395

matouskozak opened this issue Jan 14, 2025 · 0 comments
Labels
area-System.Data.SqlClient untriaged New issue has not been triaged by the area owner

Comments

@matouskozak
Copy link
Member

matouskozak commented Jan 14, 2025

Some SqlString APIs are relying on LCID numbers to represent users' cultures, e.g.,

public SqlString(string? data) : this(data, System.Globalization.CultureInfo.CurrentCulture.LCID, s_iDefaultFlag)

This can cause issues when user's culture is not part of https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Globalization/IcuLocaleData.cs (e.g., en-CZ), causing the returned LCID to be 0x1000 (LOCALE_CUSTOM_UNSPECIFIED), that is not acceptable by some CultureInfo APIs, e.g.,

public static CultureInfo GetCultureInfo(int culture)


The use of LCID is not recommended:

Note that LCIDs are being deprecated, and implementers are strongly encouraged to use newer versions of APIs that support BCP 47 locale names instead. Each LCID can be represented by a BCP 47 locale name, but the reverse is not true. The LCID range is restricted and unable to uniquely identify all the possible combinations of language and region.

https://learn.microsoft.com/en-us/globalization/locale/other-locale-names#lcid and the use of culture names is preferred.

cc: @tarekgh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Data.SqlClient untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

No branches or pull requests

1 participant