Skip to content

Commit

Permalink
Add patch to fix registry string encoding
Browse files Browse the repository at this point in the history
... to ruby-3.3 and -head for now

Fixes: oneclick/rubyinstaller2#348
  • Loading branch information
larskanis committed Dec 25, 2023
1 parent 8414492 commit 1b3ff52
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
From be7f76870b3e6abb56c24b60710a00b25bc3f4cf Mon Sep 17 00:00:00 2001
From: Lars Kanis <larskanis@gmail.com>
Date: Mon, 25 Dec 2023 15:53:47 +0100
Subject: [PATCH] [Win32] Return registry strings as UTF-8

Since ruby-3.0 usually all strings from the Windows-API are returned as UTF-8 strings.
Win32::Registry so far returned OEM encoding.
This was a leftover from 2.x times.
This commit changes it to UTF-8.

Fixes: https://github.com/oneclick/rubyinstaller2/issues/348
---
ext/win32/lib/win32/registry.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ext/win32/lib/win32/registry.rb b/ext/win32/lib/win32/registry.rb
index b5b99ff684..91f666cdd7 100644
--- a/ext/win32/lib/win32/registry.rb
+++ b/ext/win32/lib/win32/registry.rb
@@ -69,7 +69,7 @@ module Win32
WCHAR_NUL = "\0".encode(WCHAR).freeze
WCHAR_CR = "\r".encode(WCHAR).freeze
WCHAR_SIZE = WCHAR_NUL.bytesize
- LOCALE = Encoding.find(Encoding.locale_charmap)
+ LOCALE = Encoding::UTF_8

class Registry

--
2.26.0.windows.1

3 changes: 3 additions & 0 deletions mingw-w64-ruby-head/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ options=('staticlibs' 'strip')
source=("https://cache.ruby-lang.org/pub/ruby/snapshot/snapshot-master.tar.xz"
0001-Add-C-ext-win32-dll_directory-as-an-alternative-to-f.patch
0002-Don-t-add-an-exe-file-manifest.patch
0009-Win32-Return-registry-strings-as-UTF-8.patch
ruby.ico
rubyw.ico)
noextract=("snapshot-master.tar.xz")
Expand All @@ -32,6 +33,7 @@ noextract=("snapshot-master.tar.xz")
sha256sums=('SKIP'
'a50c81ab8c178689485257f8eaa70bd8184b878a798780084668f838912e2832'
'da079dbfdc3d4e1b976ed15d58244ed6e0df201ec829bead578fb4a7177b9cab'
'd221e357861ff3f46f29de978cc00a8f12ffdd865a5d8c1783f3e31e34675808'
'6c80ba2ca49840e387a08b7fedc6e7acd298ac2ec853155209efb2af20397b22'
'c30fb04ac0e88ba634daaa811a81ea5a75027646617b895acd14df9518a4a55a')

Expand All @@ -41,6 +43,7 @@ prepare() {
rm -rf ext/win32/dll_directory
patch -p1 -i ${srcdir}/0001-Add-C-ext-win32-dll_directory-as-an-alternative-to-f.patch
patch -p1 -i ${srcdir}/0002-Don-t-add-an-exe-file-manifest.patch
patch -p1 -i ${srcdir}/0009-Win32-Return-registry-strings-as-UTF-8.patch
autoreconf -fi
}

Expand Down
31 changes: 31 additions & 0 deletions mingw-w64-ruby33/0009-Win32-Return-registry-strings-as-UTF-8.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
From be7f76870b3e6abb56c24b60710a00b25bc3f4cf Mon Sep 17 00:00:00 2001
From: Lars Kanis <larskanis@gmail.com>
Date: Mon, 25 Dec 2023 15:53:47 +0100
Subject: [PATCH] [Win32] Return registry strings as UTF-8

Since ruby-3.0 usually all strings from the Windows-API are returned as UTF-8 strings.
Win32::Registry so far returned OEM encoding.
This was a leftover from 2.x times.
This commit changes it to UTF-8.

Fixes: https://github.com/oneclick/rubyinstaller2/issues/348
---
ext/win32/lib/win32/registry.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ext/win32/lib/win32/registry.rb b/ext/win32/lib/win32/registry.rb
index b5b99ff684..91f666cdd7 100644
--- a/ext/win32/lib/win32/registry.rb
+++ b/ext/win32/lib/win32/registry.rb
@@ -69,7 +69,7 @@ module Win32
WCHAR_NUL = "\0".encode(WCHAR).freeze
WCHAR_CR = "\r".encode(WCHAR).freeze
WCHAR_SIZE = WCHAR_NUL.bytesize
- LOCALE = Encoding.find(Encoding.locale_charmap)
+ LOCALE = Encoding::UTF_8

class Registry

--
2.26.0.windows.1

3 changes: 3 additions & 0 deletions mingw-w64-ruby33/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ options=('staticlibs' 'strip')
source=("https://cache.ruby-lang.org/pub/ruby/${pkgver2%.*}/${_realname}-${pkgver2}.tar.xz"
0001-Add-C-ext-win32-dll_directory-as-an-alternative-to-f.patch
0002-Don-t-add-an-exe-file-manifest.patch
0009-Win32-Return-registry-strings-as-UTF-8.patch
ruby.ico
rubyw.ico)

Expand All @@ -30,6 +31,7 @@ source=("https://cache.ruby-lang.org/pub/ruby/${pkgver2%.*}/${_realname}-${pkgve
sha256sums=('676b65a36e637e90f982b57b059189b3276b9045034dcd186a7e9078847b975b'
'a50c81ab8c178689485257f8eaa70bd8184b878a798780084668f838912e2832'
'da079dbfdc3d4e1b976ed15d58244ed6e0df201ec829bead578fb4a7177b9cab'
'd221e357861ff3f46f29de978cc00a8f12ffdd865a5d8c1783f3e31e34675808'
'6c80ba2ca49840e387a08b7fedc6e7acd298ac2ec853155209efb2af20397b22'
'c30fb04ac0e88ba634daaa811a81ea5a75027646617b895acd14df9518a4a55a')

Expand All @@ -38,6 +40,7 @@ prepare() {
rm -rf ext/win32/dll_directory
patch -p1 -i ${srcdir}/0001-Add-C-ext-win32-dll_directory-as-an-alternative-to-f.patch
patch -p1 -i ${srcdir}/0002-Don-t-add-an-exe-file-manifest.patch
patch -p1 -i ${srcdir}/0009-Win32-Return-registry-strings-as-UTF-8.patch
}

build() {
Expand Down

0 comments on commit 1b3ff52

Please sign in to comment.