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
unstable
HD Moore 2009-05-12 20:04:23 +00:00
parent 0981295879
commit 2a5060a934
2 changed files with 7 additions and 7 deletions

View File

@ -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

View File

@ -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