Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Workaround for JRuby bug with UTF-8 encoding on non-English Windows #3767
We discovered this with a customer yesterday. DNS resolving (using
The bug only appears if:
Here is a test script that reproduces the problem given that you have a Swedish Windows:
require 'win32/resolv' puts Encoding.locale_charmap puts Win32::Resolv.send(:get_info).inspect
Since I don't have a Swedish Windows, I managed to reproduce the same error locally by adding this code into the
msg = "Malm\xf6, G\xf6teborg och V\xe4xj\xf6"
That gives me the same error:
Now, to the solution. The "correct" approach would be to not use the ANSI version of the system call at all, but instead use the "wide" version. This is the approach MRI has taken, the bug was fixed there almost 3 years ago. :) ruby/ruby@9db6beb is the specific commit, fixing the bug reported in this issue: https://bugs.ruby-lang.org/issues/8508
I tried that first, by copying over their current version of the
Therefore, I tried with a simpler workaround instead: if we get an exception in this method, let's just retry by fetching the
It wasn't applicable straight away, since it relied on stuff we don't use (like
Anyway, I did a bit of a "compromise" now, bringing in the essence of their change but making it work in our codebase. Have tested it locally and this version now works fine on my machine at least; will verify with customer as well.
@perlun great! I think we have not updated this impl because of the deps it uses in future revisions. Without supporting those we might need to get a little more inventive like this and probably change any other A signatures to W signatures. This gets you past your current hurdle though so let's roll with it. Thanks for the PR and followup work.
@perlun yeah we anticipate it within the next week or so. We actually have slipped a few times but we are spending some extra time to make sure we get appveyor CI runs more green on windows. In theory, 1.7.25 and 9.1 will be the most tested releases against windows in a long time. We will not end up fixing all windows issues but hopefully will be on a much better support trajectory.