From: "NARUSE, Yui" Date: 2008-02-07T08:17:13+09:00 Subject: Re: STDIN encoding differs from default source file encoding Dave Thomas wrote: > This seems strange: > > dave[RUBY3/Book 16:03:45] echo 'p __ENCODING__' > t.rb > dave[RUBY3/Book 16:03:51] ruby t.rb > # > dave[RUBY3/Book 16:03:55] cat t.rb | ruby > # This is spec. STDIN encoding will be locale when no magic comment and -K and -E. Following is the table of default string literal encoding, produced by Nakamura. [ruby-dev:33389] Normal script case | script encoding | default external | ------------------------------+-----------------+------------------+ no -K -E, no magic comment | US-ASCII | locale | no -K -E, have magic comment | magic comment | locale | have -E, no magic comment | US-ASCII | -E | have -E, have magic comment | magic comment | -E | have -K, no magic comment | -K | -K | have -K, have magic comment | magic comment | -K | -e and stdin case | script encoding | default external | ------------------------------+-----------------+------------------+ no -K -E, no magic comment | locale | locale | no -K -E, have magic comment | magic comment | locale | have -E, no magic comment | locale | -E | have -E, have magic comment | magic comment | -E | have -K, no magic comment | -K | -K | have -K, have magic comment | magic comment | -K | -- NARUSE, Yui DBDB A476 FDBD 9450 02CD 0EFC BCE3 C388 472E C1EA