1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-09-24 07:39:41 +00:00
parent 14695c4c1a
commit 79e880c90d
2 changed files with 20 additions and 2 deletions

View file

@ -1,3 +1,13 @@
Tue Sep 24 16:39:36 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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@ruby-lang.org>
* ext/win32/lib/win32/registry.rb (Win32::Registry::API#EnumKey):

View file

@ -290,7 +290,7 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
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.microsoft.com/library/en-us/sysinfo/base/pr
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.microsoft.com/library/en-us/sysinfo/base/pr
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.microsoft.com/library/en-us/sysinfo/base/pr
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.microsoft.com/library/en-us/sysinfo/base/pr
end
__END__
end
private
def export_string(str, enc = Encoding.default_internal || LOCALE) # :nodoc:
str.encode(enc)
end
end
end