ruby-changes:30951
From: nobu <ko1@a...>
Date: Tue, 24 Sep 2013 16:39:48 +0900 (JST)
Subject: [ruby-changes:30951] nobu:r43030 (trunk): win32/registry.rb: encode name
nobu 2013-09-24 16:39:41 +0900 (Tue, 24 Sep 2013) New Revision: 43030 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43030 Log: win32/registry.rb: encode name * ext/win32/lib/win32/registry.rb (Win32::Registry#each_value): encode name. * ext/win32/lib/win32/registry.rb (Win32::Registry#each_key): ditto. * ext/win32/lib/win32/registry.rb (Win32::Registry#export_string): encode to locale encoding if default internal is not set. Modified files: trunk/ChangeLog trunk/ext/win32/lib/win32/registry.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 43029) +++ ChangeLog (revision 43030) @@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Sep 24 16:39:36 2013 Nobuyoshi Nakada <nobu@r...> + + * ext/win32/lib/win32/registry.rb (Win32::Registry#each_value): encode + name. + + * ext/win32/lib/win32/registry.rb (Win32::Registry#each_key): ditto. + + * ext/win32/lib/win32/registry.rb (Win32::Registry#export_string): + encode to locale encoding if default internal is not set. + Tue Sep 24 16:35:09 2013 Nobuyoshi Nakada <nobu@r...> * ext/win32/lib/win32/registry.rb (Win32::Registry::API#EnumKey): Index: ext/win32/lib/win32/registry.rb =================================================================== --- ext/win32/lib/win32/registry.rb (revision 43029) +++ ext/win32/lib/win32/registry.rb (revision 43030) @@ -290,7 +290,7 @@ For detail, see the MSDN[http://msdn.mic https://github.com/ruby/ruby/blob/trunk/ext/win32/lib/win32/registry.rb#L290 name = WCHAR_NUL * Constants::MAX_KEY_LENGTH size = packdw(Constants::MAX_KEY_LENGTH) check RegEnumValueW.call(hkey, index, name, size, 0, 0, 0, 0) - name[0, unpackdw(size)].encode + name[0, unpackdw(size)] end def EnumKey(hkey, index) @@ -298,7 +298,7 @@ For detail, see the MSDN[http://msdn.mic https://github.com/ruby/ruby/blob/trunk/ext/win32/lib/win32/registry.rb#L298 size = packdw(Constants::MAX_KEY_LENGTH) wtime = ' ' * 8 check RegEnumKeyExW.call(hkey, index, name, size, 0, 0, 0, wtime) - [ name[0, unpackdw(size)].encode, unpackqw(wtime) ] + [ name[0, unpackdw(size)], unpackqw(wtime) ] end def QueryValue(hkey, name) @@ -558,6 +558,7 @@ For detail, see the MSDN[http://msdn.mic https://github.com/ruby/ruby/blob/trunk/ext/win32/lib/win32/registry.rb#L558 rescue Error break end + subkey = export_string(subkey) begin type, data = read(subkey) rescue Error @@ -594,6 +595,7 @@ For detail, see the MSDN[http://msdn.mic https://github.com/ruby/ruby/blob/trunk/ext/win32/lib/win32/registry.rb#L595 rescue Error break end + subkey = export_string(subkey) yield subkey, wtime index += 1 end @@ -883,5 +885,11 @@ For detail, see the MSDN[http://msdn.mic https://github.com/ruby/ruby/blob/trunk/ext/win32/lib/win32/registry.rb#L885 end __END__ end + + private + + def export_string(str, enc = Encoding.default_internal || LOCALE) # :nodoc: + str.encode(enc) + end end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/