class String BTOW = Win32API.new("Kernel32", "MultiByteToWideChar", %w(i i p i p i), "i") WTOB = Win32API.new("Kernel32", "WideCharToMultiByte", %w(i i p i p i p i), "i") attr_reader :type alias :base_initialize :initialize def initialize base_initialize @type = 65001 end def conv(type) l = self.size * 2 baffa = "\0" * l result = "\0" * l BTOW.call(@type, 0, self, -1, baffa, l) case type when "utf8" @type = 65001 when "szis" @type = 0 when "utf7" @type = 65000 when "uni" return result.gsub(/\0/){} else print "それは文字コードではないか、現在対応していません。" return end WTOB.call(@type, 0, baffa, -1, result, l, nil, 0) return result.gsub(/\0/){} end def szis l = self.size * 2 baffa = "\0" * l result = "\0" * l BTOW.call(65001, 0, self, -1, baffa, l) WTOB.call(0, 0, baffa, -1, result, l, nil, 0) return result.gsub(/\0/){} end def utf8 l = self.size * 2 baffa = "\0" * l result = "\0" * l BTOW.call(0, 0, self, -1, baffa, l) WTOB.call(65001, 0, baffa, -1, result, l, nil, 0) return result.gsub(/\0/){} end end