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

Fix MacVim's locale not having encoding when launched from Dock #1036

Merged
merged 1 commit into from
Apr 10, 2020

Conversation

ychin
Copy link
Member

@ychin ychin commented Apr 10, 2020

When launching MacVim not from terminal, macOS doesn't set the $LANG environment variable, and the locale API doesn't have a way to return the encoding (probably because everything is UTF-8). As such Vim would set the locale to something like "en_US", which breaks certain tools that expects an encoding part set.

Fix this by simply appending ".UTF-8" to the constructed locale (e.g. "en_US.UTF-8") if $LANG doesn't exist. This makes sense as we default to UTF-8 in MacVim and macOS is basically UTF-8 native anyway.

Also, add a test that will make sure this is the case.

Fix #1033

@ychin ychin force-pushed the fix-locale-encoding-launched-dock branch from 4442bd7 to cf4a749 Compare April 10, 2020 10:56
When launching MacVim not from terminal, macOS doesn't set the $LANG
environment variable, and the locale API doesn't have a way to return
the encoding (probably because everything is UTF-8). As such Vim would
set the locale to something like "en_US", which breaks certain tools
that expects an encoding part set.

Fix this by simply appending ".UTF-8" to the constructed locale (e.g.
"en_US.UTF-8") if $LANG doesn't exist. This makes sense as we default to
UTF-8 in MacVim and macOS is basically UTF-8 native anyway.

Also, add a test that will make sure this is the case.

Fix macvim-dev#1033
@ychin ychin force-pushed the fix-locale-encoding-launched-dock branch from cf4a749 to 4b76a9f Compare April 10, 2020 11:48
@ychin ychin merged commit 86f13d5 into macvim-dev:master Apr 10, 2020
@ychin ychin deleted the fix-locale-encoding-launched-dock branch April 10, 2020 19:08
ychin added a commit to ychin/vim that referenced this pull request Sep 27, 2020
If LANG is unset in macOS (either manually or when launching GUI version
of Vim from the Dock where this environmental variable is not set by the
OS), Vim tries to query the system locale and set that. However, the
system API doesn't set the encoding part, and there are tools like new
versions of Python that seems to want to have an explicit encoding bit
set. Also, macOS defaults to UTF-8 anyway, so just make sure to append
".UTF-8" to the locale to explicitly set it.

Also, add regression test for both this change and for 509f803 (vim#7003)
which added logic to make sure we set LC_NUMERIC to "C" in the default
locale detection.

This is a port of macvim-dev/macvim#1036
ychin added a commit to ychin/vim that referenced this pull request Sep 27, 2020
If LANG is unset in macOS (either manually or when launching GUI version
of Vim from the Dock where this environmental variable is not set by the
OS), Vim tries to query the system locale and set that. However, the
system API doesn't set the encoding part, and there are tools like new
versions of Python that seems to want to have an explicit encoding bit
set. Also, macOS defaults to UTF-8 anyway, so just make sure to append
".UTF-8" to the locale to explicitly set it.

Also, add regression test for both this change and for 509f803 (vim#7003)
which added logic to make sure we set LC_NUMERIC to "C" in the default
locale detection.

This is a port of macvim-dev/macvim#1036
ychin added a commit to ychin/vim that referenced this pull request Sep 27, 2020
If LANG is unset in macOS (either manually or when launching GUI version
of Vim from the Dock where this environmental variable is not set by the
OS), Vim tries to query the system locale and set that. However, the
system API doesn't set the encoding part, and there are tools like new
versions of Python that seems to want to have an explicit encoding bit
set. Also, macOS defaults to UTF-8 anyway, so just make sure to append
".UTF-8" to the locale to explicitly set it.

Also, add regression test for both this change and for 509f803 (vim#7003)
which added logic to make sure we set LC_NUMERIC to "C" in the default
locale detection.

This is a port of macvim-dev/macvim#1036
ychin added a commit to ychin/vim that referenced this pull request Sep 27, 2020
If LANG is unset in macOS (either manually or when launching GUI version
of Vim from the Dock where this environmental variable is not set by the
OS), Vim tries to query the system locale and set that. However, the
system API doesn't set the encoding part, and there are tools like new
versions of Python that seems to want to have an explicit encoding bit
set. Also, macOS defaults to UTF-8 anyway, so just make sure to append
".UTF-8" to the locale to explicitly set it.

Also, add regression test for both this change and for 509f803 (vim#7003)
which added logic to make sure we set LC_NUMERIC to "C" in the default
locale detection.

This is a port of macvim-dev/macvim#1036
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.

Python error when executing :shell or :term
1 participant