Skip to content

Remove dependencies on culture LCID inside SqlString codebase #111395

Open
@matouskozak

Description

@matouskozak

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions