summaryrefslogtreecommitdiff
path: root/test/win32ole
diff options
context:
space:
mode:
authorsuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-27 23:43:57 +0000
committersuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-27 23:43:57 +0000
commitdd024197601d884b145edbd240707b91ceda95d8 (patch)
treeec7629643d8bb1871a401cf5f01f039dc718775d /test/win32ole
parentd080d174f5cd7d001bacdc8e53f4d42596ca86b9 (diff)
* ext/win32ole/win32ole.c : check String encoding when
converting String to VT_BSTR in OLE. * test/win32ole/test_win32ole.rb : ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/win32ole')
-rw-r--r--test/win32ole/test_win32ole.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/test/win32ole/test_win32ole.rb b/test/win32ole/test_win32ole.rb
index a79434f..0a9c50b 100644
--- a/test/win32ole/test_win32ole.rb
+++ b/test/win32ole/test_win32ole.rb
@@ -282,8 +282,8 @@ if defined?(WIN32OLE)
fso = WIN32OLE.new("Scripting.FileSystemObject")
fname = fso.getTempName
begin
+ obj = WIN32OLE_VARIANT.new([0x3042].pack("U*").force_encoding("UTF-8"))
WIN32OLE.codepage = WIN32OLE::CP_UTF8
- obj = WIN32OLE_VARIANT.new([0x3042].pack("U*"))
assert_equal("\xE3\x81\x82".force_encoding("CP65001"), obj.value)
begin
@@ -302,9 +302,9 @@ if defined?(WIN32OLE)
assert_equal("\xA4\xA2".force_encoding("CP20932"), obj.value)
end
- WIN32OLE.codepage = WIN32OLE::CP_UTF8
+ WIN32OLE.codepage = cp
file = fso.opentextfile(fname, 2, true)
- file.write [0x3042].pack("U*")
+ file.write [0x3042].pack("U*").force_encoding("UTF-8")
file.close
str = ""
open(fname, "r:ascii-8bit") {|ifs|
@@ -318,8 +318,9 @@ if defined?(WIN32OLE)
rescue WIN32OLERuntimeError
end
if (WIN32OLE.codepage == 20932)
+ WIN32OLE.codepage = cp
file = fso.opentextfile(fname, 2, true)
- file.write [164, 162].pack("c*")
+ file.write [164, 162].pack("c*").force_encoding("EUC-JP")
file.close
open(fname, "r:ascii-8bit") {|ifs|
str = ifs.read