diff --git a/lib/gems/pending/util/miq-unicode.rb b/lib/gems/pending/util/miq-unicode.rb deleted file mode 100644 index 67ba4b825..000000000 --- a/lib/gems/pending/util/miq-unicode.rb +++ /dev/null @@ -1,43 +0,0 @@ -class String - # See Programming Ruby 1.9 - The Pragmatic Programmers’ Guide - # Figure 17.1. "Encodings and Their Aliases" in the for available encodings. - def UnicodeToUtf8 - dup.force_encoding("UTF-16LE").encode("UTF-8") - end - - def UnicodeToUtf8! - force_encoding("UTF-16LE").encode!("UTF-8") - end - - def Utf8ToUnicode - dup.force_encoding("UTF-8").encode("UTF-16LE") - end - - def Utf8ToUnicode! - force_encoding("UTF-8").encode!("UTF-16LE") - end - - def AsciiToUtf8 - dup.force_encoding("ISO-8859-1").encode("UTF-8") - end - - def AsciiToUtf8! - force_encoding("ISO-8859-1").encode!("UTF-8") - end - - def Utf8ToAscii - dup.force_encoding("UTF-8").encode("ISO-8859-1") - end - - def Utf8ToAscii! - force_encoding("UTF-8").encode!("ISO-8859-1") - end - - def Ucs2ToAscii - dup.force_encoding("UTF-16LE").encode("ISO-8859-1") - end - - def Ucs2ToAscii! - force_encoding("UTF-16LE").encode!("ISO-8859-1") - end -end diff --git a/lib/gems/pending/util/win32/miq-powershell.rb b/lib/gems/pending/util/win32/miq-powershell.rb index 3b4db4932..b890c023e 100644 --- a/lib/gems/pending/util/win32/miq-powershell.rb +++ b/lib/gems/pending/util/win32/miq-powershell.rb @@ -3,7 +3,6 @@ require 'io/wait' require 'open-uri' require 'util/miq-encode' -require 'util/miq-unicode' require 'win32/registry' if Sys::Platform::OS == :windows module MiqPowerShell @@ -94,7 +93,8 @@ def self.is_error_object?(xml) end def self.run_script(script) - encoded_command = MIQEncode.encode(script.AsciiToUtf8.Utf8ToUnicode, false) + string = script.dup.force_encoding("ISO-8859-1").encode("UTF-16LE") + encoded_command = MIQEncode.encode(string, false) ps_command = "-EncodedCommand #{encoded_command}" execute(ps_command) end diff --git a/spec/util/miq-unicode_spec.rb b/spec/util/miq-unicode_spec.rb deleted file mode 100644 index c69788482..000000000 --- a/spec/util/miq-unicode_spec.rb +++ /dev/null @@ -1,93 +0,0 @@ -require 'util/miq-unicode' - -describe 'miq-unicode' do - context "with Unicode and UTF-8 data" do - before(:each) do - @unicode_str = "S\000Y\000S\000T\000E\000M\000\000\000\000\000\000\000" - @utf8_str = "SYSTEM\000\000\000" - - @unicode_str.force_encoding("UTF-16LE") - @utf8_str.force_encoding("UTF-8") - end - - it '.UnicodeToUtf8' do - converted_utf8 = @unicode_str.UnicodeToUtf8 - expect(converted_utf8.object_id).not_to eq(@unicode_str.object_id) - expect(converted_utf8).to eq(@utf8_str) - end - - it '.UnicodeToUtf8!' do - converted_utf8 = @unicode_str.UnicodeToUtf8! - expect(converted_utf8.object_id).to eq(@unicode_str.object_id) - expect(converted_utf8).to eq(@utf8_str) - end - - it '.Utf8ToUnicode' do - converted_unicode = @utf8_str.Utf8ToUnicode - expect(converted_unicode.object_id).not_to eq(@utf8_str.object_id) - expect(converted_unicode).to eq(@unicode_str) - end - - it '.Utf8ToUnicode!' do - converted_unicode = @utf8_str.Utf8ToUnicode! - expect(converted_unicode.object_id).to eq(@utf8_str.object_id) - expect(converted_unicode).to eq(@unicode_str) - end - end - - context "with UTF-8 and ASCII data" do - before(:each) do - @utf8_str = "123\303\245456" - @ascii_str = "123\345456" - - @utf8_str.force_encoding("UTF-8") - @ascii_str.force_encoding("ISO-8859-1") - end - - it '.AsciiToUtf8' do - converted_utf8 = @ascii_str.AsciiToUtf8 - expect(converted_utf8.object_id).not_to eq(@ascii_str.object_id) - expect(converted_utf8).to eq(@utf8_str) - end - - it '.AsciiToUtf8!' do - converted_utf8 = @ascii_str.AsciiToUtf8! - expect(converted_utf8.object_id).to eq(@ascii_str.object_id) - expect(converted_utf8).to eq(@utf8_str) - end - - it '.Utf8ToAscii' do - converted_ascii = @utf8_str.Utf8ToAscii - expect(converted_ascii.object_id).not_to eq(@utf8_str.object_id) - expect(converted_ascii).to eq(@ascii_str) - end - - it '.Utf8ToAscii!' do - converted_ascii = @utf8_str.Utf8ToAscii! - expect(converted_ascii.object_id).to eq(@utf8_str.object_id) - expect(converted_ascii).to eq(@ascii_str) - end - end - - context "with ASCII and UCS-2 data" do - before(:each) do - @ucs2_str = "1\000.\0008\000.\0007\000" - @ascii_str = "1.8.7" - - @ucs2_str.force_encoding("UTF-16LE") - @ascii_str.force_encoding("ISO-8859-1") - end - - it '.Ucs2ToAscii' do - converted_ascii = @ucs2_str.Ucs2ToAscii - expect(converted_ascii.object_id).not_to eq(@ucs2_str.object_id) - expect(converted_ascii).to eq(@ascii_str) - end - - it '.Ucs2ToAscii!' do - converted_ascii = @ucs2_str.Ucs2ToAscii! - expect(converted_ascii.object_id).to eq(@ucs2_str.object_id) - expect(converted_ascii).to eq(@ascii_str) - end - end -end