Skip to content

Commit

Permalink
fix UTF16 BOM removal problem on ruby 1.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mccraigmccraig committed Jun 1, 2011
1 parent ded9ce3 commit ef41474
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -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]

Expand Down
8 changes: 6 additions & 2 deletions lib/net/ntlm.rb
Expand Up @@ -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)
Expand Down

0 comments on commit ef41474

Please sign in to comment.