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

Use C locale instead of en_US #210506

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

i-ky
Copy link

@i-ky i-ky commented Apr 16, 2024

Not everybody speaks English and not everyone lives in the United States, so it is not given that en_US locale will be available on the system. C, however, must always be present on a (POSIX-compliant?) system, because it is selected as default on startup of the program, see https://man7.org/linux/man-pages/man3/setlocale.3.html The latter is therefore a much safer choice of a locale used to force English as output language, . as a decimal separator etc.

Resolves #189924.

Not everybody speaks English and not everyone lives in the United States, so it is not given that `en_US` locale will be available on the system.
`C`, however, must always be present on a (POSIX-compliant?) system, because it is selected as default on startup of the program, see https://man7.org/linux/man-pages/man3/setlocale.3.html
The latter is therefore a much safer choice of a locale used to force English as output language, `.` as a decimal separator etc.

Resolves microsoft#189924.
@i-ky
Copy link
Author

i-ky commented Apr 16, 2024

Note that there are a few more places that can potentially benefit from a similar change:

// Set numeric locale to ensure '.' is used as the decimal separator
exec(`${ps} ${args}`, { maxBuffer: 1000 * 1024, env: { LC_NUMERIC: 'en_US.UTF-8' } }, (err, stdout, stderr) => {

exec('lsof -OPln -p ' + this._ptyProcess.pid + ' | grep cwd', { env: { ...process.env, LANG: 'en_US.UTF-8' } }, (error, stdout, stderr) => {

// Fallback to en_US if the locale is unknown
return 'en_US.UTF-8';

@gone-for-coding
Copy link

@lszomoru do you mind having a look at this PR please? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VScode force changes the locale to en_US.UTF-8 for git commit hooks in dev-container
3 participants