Forum: Ruby-core __FILE__.encoding is wrong

F1d6cc2b735bfd82c8773172da2aeab9?d=identicon&s=25 Nobuyoshi Nakada (nobu)
on 2013-08-09 14:36
(Received via mailing list)
Issue #8753 has been updated by nobu (Nobuyoshi Nakada).

Description updated

Bug #8753: __FILE__.encoding is wrong

Author: (贾 延平)
Status: Open
Priority: Normal
Assignee: naruse (Yui NARUSE)
Target version:
ruby -v: ruby 2.1.0dev (2013-08-06) [i386-mingw32]
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN

A bug introduced by change r42183
(({__FILE__}))'s encoding is wrong.
In file ((%ruby.c%)) and function (({load_file_internal})) type
(({VALUE})) convert to (({char*})), and lost the encoding info
  const char *orig_fname = StringValueCStr(argp->fname);
and call the (({rb_parser_compile_file})) with the (({char*})) variable
  tree = rb_parser_compile_file(parser, orig_fname, f, line_start);
and in file ((%parse.y%)) and function (({rb_parser_compile_file})),
type (({char*})) convert to (({VALUE})) using the ((*filesystem
  return rb_parser_compile_file_path(vparser,
rb_filesystem_str_new_cstr(f), file, start);
But the beginning parameter ((*(({argp->fname}))'s encoding*)) not the
((*filesystem encoding*)).

What's the principle of ruby's encoding?Why so many (({VALUE})) to
(({char*})) converting?Is the (({char*})) has the regular encoding?

I think we should convert the encoding at the boundary and every thing
should encoding to internal encoding in the internal, am I right?
This topic is locked and can not be replied to.