summaryrefslogtreecommitdiff
path: root/ext/win32/lib/win32
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-24 07:39:41 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-24 07:39:41 +0000
commit79e880c90df6938e8226336a883d1973031da3df (patch)
tree6476a626b1246f43bf32206b6219ae4981788fe6 /ext/win32/lib/win32
parent14695c4c1aed1067d73dca044d3367c54f3b5565 (diff)
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
Diffstat (limited to 'ext/win32/lib/win32')
-rw-r--r--ext/win32/lib/win32/registry.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/ext/win32/lib/win32/registry.rb b/ext/win32/lib/win32/registry.rb
index d989bc0..668f573 100644
--- a/ext/win32/lib/win32/registry.rb
+++ b/ext/win32/lib/win32/registry.rb
@@ -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