summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Calvert <athemeus@athemeus.com>2024-09-06 22:19:47 -0500
committerTakashi Kokubun <takashikkbn@gmail.com>2024-11-04 14:26:25 -0800
commit7446f7cdd103b129b8b750f577efd29e069176c0 (patch)
treeaf3fad032aee0db4f1a0947fed73f2d1c08fac41
parent6b3a0b4ffd12cd7f80be224efa8744534fcf2b93 (diff)
merge revision(s) 0d16c36d0ab2afa2ec79b72b229e69c141ebdaba: [Backport #13831]
[win32/registry] Fallback to UTF-8 for unknown codepages There are some codepages like cp708 for which no ruby encoding exists: $ ruby -e "Encoding.find('cp708')" Traceback (most recent call last): 1: from -e:1:in `<main>' -e:1:in `find': unknown encoding name - cp708 (ArgumentError) win32/registry uses ENCODING to transcode error messages and expand environment variables from UTF-16LE, so using UTF-8 seems like the best choice and is better than a hard failure. This should resolve [Bug #13831]
-rw-r--r--ext/win32/lib/win32/registry.rb6
-rw-r--r--version.h2
2 files changed, 6 insertions, 2 deletions
diff --git a/ext/win32/lib/win32/registry.rb b/ext/win32/lib/win32/registry.rb
index 16a08310ad..bda8bb012f 100644
--- a/ext/win32/lib/win32/registry.rb
+++ b/ext/win32/lib/win32/registry.rb
@@ -69,7 +69,11 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
WCHAR_NUL = "\0".encode(WCHAR).freeze
WCHAR_CR = "\r".encode(WCHAR).freeze
WCHAR_SIZE = WCHAR_NUL.bytesize
- LOCALE = Encoding.find(Encoding.locale_charmap)
+ begin
+ LOCALE = Encoding.find(Encoding.locale_charmap)
+ rescue ArgumentError
+ LOCALE = Encoding::UTF_8
+ end
class Registry
diff --git a/version.h b/version.h
index 0878029542..04e3d8fba4 100644
--- a/version.h
+++ b/version.h
@@ -11,7 +11,7 @@
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
#define RUBY_VERSION_TEENY 5
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 100
+#define RUBY_PATCHLEVEL 101
#include "ruby/version.h"
#include "ruby/internal/abi.h"