diff --git a/Rakefile b/Rakefile index 654f919..68fe575 100644 --- a/Rakefile +++ b/Rakefile @@ -9,7 +9,7 @@ require File.join(File.dirname(__FILE__), 'lib', 'net', 'ntlm') #PKG_NAME = 'rubyntlm' PKG_NAME = 'pyu-ntlm-http' -PKG_VERSION = "0.1.3.1" +PKG_VERSION = "0.1.3.2" task :default => [:test] diff --git a/lib/net/ntlm.rb b/lib/net/ntlm.rb index ed8b9ef..ee366c6 100644 --- a/lib/net/ntlm.rb +++ b/lib/net/ntlm.rb @@ -100,8 +100,12 @@ def decode_utf16le(str) end def encode_utf16le(str) - # Kconv on JRUBY outputs a BOM... so strip that - swap16(Kconv.kconv(str, Kconv::UTF16, Kconv::ASCII).gsub(/^\376\377/,'')) + if str.respond_to?(:encode) # ruby 1.9 / jruby --1.9 + str.encode("UTF-16LE").force_encoding("ASCII-8BIT") + else + # Kconv on JRUBY outputs a BOM... so strip that + swap16(Kconv.kconv(str, Kconv::UTF16, Kconv::ASCII).gsub(/^\376\377/,'')) + end end def pack_int64le(val)