Permalink
Browse files

* file.c (win32_io_info): UTF-8 handling.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/win32-unicode-test@25349 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
1 parent 75f3532 commit d1010584b9a7dd49f50bccb4483bb2c3f3a0c0ee @unak unak committed Oct 15, 2009
Showing with 10 additions and 1 deletion.
  1. +4 −0 ChangeLog
  2. +6 −1 file.c
View
@@ -1,3 +1,7 @@
+Thu Oct 15 15:02:29 2009 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * file.c (win32_io_info): UTF-8 handling.
+
Thu Oct 15 14:52:34 2009 NAKAMURA Usaku <usa@ruby-lang.org>
* file.c (rb_str_encode_ospath): no more gurantee that the returned
View
7 file.c
@@ -806,9 +806,14 @@ w32_io_info(VALUE *file, BY_HANDLE_FILE_INFORMATION *st)
}
else {
VALUE tmp;
+ WCHAR *ptr;
+ int len;
FilePathValue(*file);
tmp = rb_str_encode_ospath(*file);
- f = CreateFileW((WCHAR *)RSTRING_PTR(tmp), 0,
+ len = MultiByteToWideChar(CP_UTF8, 0, RSTRING_PTR(tmp), -1, NULL, 0);
+ ptr = ALLOCA_N(WCHAR, len);
+ MultiByteToWideChar(CP_UTF8, 0, RSTRING_PTR(tmp), -1, ptr, len);
+ f = CreateFileW(ptr, 0,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
rb_w32_iswin95() ? 0 : FILE_FLAG_BACKUP_SEMANTICS,
NULL);

0 comments on commit d101058

Please sign in to comment.