-
-
Notifications
You must be signed in to change notification settings - Fork 683
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
ychin
merged 1 commit into
macvim-dev:master
from
ychin:fix-locale-encoding-launched-dock
Apr 10, 2020
Merged
Fix MacVim's locale not having encoding when launched from Dock #1036
ychin
merged 1 commit into
macvim-dev:master
from
ychin:fix-locale-encoding-launched-dock
Apr 10, 2020
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ychin
force-pushed
the
fix-locale-encoding-launched-dock
branch
from
April 10, 2020 10:56
4442bd7
to
cf4a749
Compare
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
force-pushed
the
fix-locale-encoding-launched-dock
branch
from
April 10, 2020 11:48
cf4a749
to
4b76a9f
Compare
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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