From 2a5060a9349c1f4bafcad4805fc55ca0a8cc97ed Mon Sep 17 00:00:00 2001 From: HD Moore Date: Tue, 12 May 2009 20:04:23 +0000 Subject: [PATCH] Fix EOF seek and use a ghetto replacement for iconv to support older ruby versions git-svn-id: file:///home/svn/framework3/trunk@6548 4d416f70-5f16-0410-b530-b9f4589650da --- lib/ole/ranges_io.rb | 2 +- lib/ole/types/base.rb | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/ole/ranges_io.rb b/lib/ole/ranges_io.rb index bfca4fe094..8e2a4320e0 100644 --- a/lib/ole/ranges_io.rb +++ b/lib/ole/ranges_io.rb @@ -95,7 +95,7 @@ class RangesIO pos = @size + pos else raise Errno::EINVAL end - raise Errno::EINVAL unless (0...@size) === pos + raise Errno::EINVAL unless (0..@size) === pos @pos = pos end diff --git a/lib/ole/types/base.rb b/lib/ole/types/base.rb index 31e7b24e98..4164db8d6c 100644 --- a/lib/ole/types/base.rb +++ b/lib/ole/types/base.rb @@ -37,16 +37,16 @@ module Ole # :nodoc: # for VT_LPWSTR class Lpwstr < String - FROM_UTF16 = Iconv.new 'utf-8', 'utf-16le' - TO_UTF16 = Iconv.new 'utf-16le', 'utf-8' + #FROM_UTF16 = Iconv.new 'utf-8', 'utf-16le' + #TO_UTF16 = Iconv.new 'utf-16le', 'utf-8' def self.load str - new FROM_UTF16.iconv(str).chomp(0.chr) + new str.unpack('v*').pack('C*').chomp(0.chr) #FROM_UTF16.iconv(str).chomp(0.chr) end def self.dump str # need to append nulls? - data = TO_UTF16.iconv str + data = str.unpack('C*').pack('v*') #TO_UTF16.iconv str # not sure if this is the recommended way to do it, but I want to treat # the resulting utf16 data as regular bytes, not characters. data.force_encoding Encoding::US_ASCII if data.respond_to? :encoding @@ -244,8 +244,8 @@ module Ole # :nodoc: Variant.load VT_FILETIME, str end - FROM_UTF16 = Lpwstr::FROM_UTF16 - TO_UTF16 = Lpwstr::TO_UTF16 + #FROM_UTF16 = Lpwstr::FROM_UTF16 + #TO_UTF16 = Lpwstr::TO_UTF16 end end