diff options
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -4885,7 +4885,26 @@ rb_scan_open_args(int argc, VALUE *argv, opt = pop_last_hash(&argc, argv); rb_scan_args(argc, argv, "12", &fname, &vmode, &vperm); FilePathValue(fname); - +#if defined _WIN32 || defined __APPLE__ + { + static rb_encoding *fs_encoding; + rb_encoding *fname_encoding = rb_enc_get(fname); + if (!fs_encoding) + fs_encoding = rb_filesystem_encoding(); + if (rb_usascii_encoding() != fname_encoding + && rb_ascii8bit_encoding() != fname_encoding +#if defined __APPLE__ + && rb_utf8_encoding() != fname_encoding +#endif + && fs_encoding != fname_encoding) { + static VALUE fs_enc; + if (!fs_enc) + fs_enc = rb_enc_from_encoding(fs_encoding); + fname = rb_str_encode(fname, fs_enc, 0, Qnil); + } + } +#endif + rb_io_extract_modeenc(&vmode, &vperm, opt, &oflags, &fmode, convconfig_p); perm = NIL_P(vperm) ? 0666 : NUM2UINT(vperm); |