Issue #14095 has been updated by k0kubun (Takashi Kokubun).


Hi Gray,

First of all, -U option of erb(1) is just the same as ruby(1)'s one, which sets both external and internal encoding to UTF-8. As those encodings are for IO, -U (or -E) is not related to the described behavior.

The actual cause that matters is source file encoding (script encoding, which affects encoding of string literal in the file) counterpart for erb(1) command. As m17n of erb(1) is implemented in Ruby 1.9, it's the same as Ruby 1.9's default source file encoding: ASCII-8BIT. But Ruby 2's default source file encoding is changed to UTF-8, I thought erb(1)'s one is changed in the same way. Thus I fixed it in r60739.

----------------------------------------
Bug #14095: erb ignores attempt to set encoding
https://bugs.ruby-lang.org/issues/14095#change-67768

* Author: graywolf (Gray Wolf)
* Status: Closed
* Priority: Normal
* Assignee: k0kubun (Takashi Kokubun)
* Target version: 
* ruby -v: ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
Erb seems to ignore any attempt to set encoding:

    $ erb -U
    <%= "a".encoding %>
    ^D
    ASCII-8BIT

I've tried multiple ways to do this but I just can't convice it that the .erb file is in UTF-8. It insists on ASCII-8BIT.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>