From: "nobu (Nobuyoshi Nakada)" Date: 2022-06-14T03:43:04+00:00 Subject: [ruby-core:108890] [Ruby master Bug#18827] `__ENCODING__` is not set to the source encoding when saving script lines Issue #18827 has been updated by nobu (Nobuyoshi Nakada). https://github.com/ruby/ruby/pull/6015 ---------------------------------------- Bug #18827: `__ENCODING__` is not set to the source encoding when saving script lines https://bugs.ruby-lang.org/issues/18827#change-97968 * Author: nobu (Nobuyoshi Nakada) * Status: Open * Priority: Normal * Assignee: nobu (Nobuyoshi Nakada) * Backport: 2.7: REQUIRED, 3.0: REQUIRED, 3.1: REQUIRED ---------------------------------------- `__ENCODING__` should respect the encoding of the given source code. ```shell-session $ ruby -Ke -e 'p __ENCODING__' # ``` ```ruby p eval("__ENCODING__".encode("euc-jp")) #=> # ``` But it is ignored when `SCRIPT_LINES__` is set. ```shell-session $ cat script_lines.rb SCRIPT_LINES__ = {} $ ruby -r./script_lines.rb -Ke -e 'p __ENCODING__' # ``` Also similar when `keep_script_lines` is true. ```ruby pp RubyVM::AbstractSyntaxTree.parse("__ENCODING__".encode("euc-jp"), keep_script_lines: true) #=> (SCOPE@1:0-1:12 tbl: [] args: nil body: (LIT@1:0-1:12 #)) ``` -- https://bugs.ruby-lang.org/ Unsubscribe: