summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--ext/win32/lib/win32/registry.rb18
2 files changed, 19 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 692b496827..cb83017b0e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Dec 23 16:03:35 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * ext/win32/lib/win32/registry.rb (Win32::Registry::Error#initialize):
+ try en_US message if the default message cannot be encoded to
+ locale. [ruby-core:65295] [Bug #10300]
+
Tue Dec 23 11:42:14 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/openssl/ossl_cipher.c (ossl_cipher_update_long): update huge
diff --git a/ext/win32/lib/win32/registry.rb b/ext/win32/lib/win32/registry.rb
index b14bd48fcf..8dcf139480 100644
--- a/ext/win32/lib/win32/registry.rb
+++ b/ext/win32/lib/win32/registry.rb
@@ -175,11 +175,19 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
def initialize(code)
@code = code
msg = WCHAR_NUL * 1024
- len = FormatMessageW.call(0x1200, 0, code, 0, msg, 1024, 0)
- msg = msg.byteslice(0, len * WCHAR_SIZE)
- msg.delete!(WCHAR_CR)
- msg.chomp!
- super msg.encode(LOCALE)
+ lang = 0
+ begin
+ len = FormatMessageW.call(0x1200, 0, code, lang, msg, 1024, 0)
+ msg = msg.byteslice(0, len * WCHAR_SIZE)
+ msg.delete!(WCHAR_CR)
+ msg.chomp!
+ msg.encode!(LOCALE)
+ rescue EncodingError
+ raise unless lang == 0
+ lang = 0x0409 # en_US
+ retry
+ end
+ super msg
end
attr_reader :code
end