From: Nobuyoshi Nakada Date: 2008-03-26T18:16:43+09:00 Subject: [ruby-dev:34139] Re: (再送) Cygwin で Resolv.getaddress が失敗する なかだです。 At Wed, 26 Mar 2008 13:38:34 +0900, Kouhei Yanagita wrote in [ruby-dev:34138]: > Cygwin では、特に自分で作成していなければ > * /etc/hosts は存在する (C:\WINDOWS\system32\drivers\etc\hosts へのシンボリックリンクになっている) > * /etc/resolv.conf は存在しない (ネットワーク設定は Windows のものが使われているようです) > ということのようです。 Win32::Resolvを使うところで require 'win32/resolv' するのがいい んじゃないでしょうか。 Index: lib/resolv.rb =================================================================== --- lib/resolv.rb (revision 15830) +++ lib/resolv.rb (working copy) @@ -778,4 +778,5 @@ class Resolv else if /mswin32|cygwin|mingw|bccwin/ =~ RUBY_PLATFORM + require 'win32/resolv' search, nameserver = Win32::Resolv.get_resolv_info config_hash = {} Index: ext/dl/win32/lib/win32/registry.rb =================================================================== --- ext/dl/win32/lib/win32/registry.rb (revision 15830) +++ ext/dl/win32/lib/win32/registry.rb (working copy) @@ -338,7 +338,8 @@ module Win32 def initialize(code) @code = code - msg = "\0" * 1024 + msg = "\0".force_encoding(Encoding::ASCII_8BIT) * 1024 len = FormatMessageA.call(0x1200, 0, code, 0, msg, 1024, 0) - super msg[0, len].tr("\r", '').chomp + msg = msg[0, len].force_encoding(Encoding.find(Encoding.locale_charmap)) + super msg.tr("\r", '').chomp end attr_reader :code -- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦