aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authork0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-10 13:59:01 +0000
committerk0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-10 13:59:01 +0000
commitd994afdd969d0c4ad04b5ecc7112a64a64392452 (patch)
treeaa844a1948a1e4861274fbf90337f3e506c749b5
parentf099b0a38d3a99dd42845b75695247be9731ac11 (diff)
downloadruby-d994afdd969d0c4ad04b5ecc7112a64a64392452.tar.gz
bin/erb: change template file encoding to UTF-8
Unlike Ruby source file encoding (script encoding) whose default is changed to UTF-8 in Ruby 2.0 (Feature #6679), template's file encoding given to erb(1) has been ASCII-8BIT since ERB supports m17n at r21170. Like Ruby source file encoding, erb template file encoding should be UTF-8 in Ruby 2. [Bug #14095] [ruby-core:83708] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60739 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--NEWS2
-rwxr-xr-xbin/erb2
-rw-r--r--test/erb/test_erb_command.rb6
3 files changed, 9 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 6388f02..3444154 100644
--- a/NEWS
+++ b/NEWS
@@ -143,6 +143,8 @@ with all sufficient information, see the ChangeLog file or Redmine
* ERB
* Add ERB#result_with_hash to render a template with local variables passed
with a Hash object. [Feature #8631]
+ * Default template file encoding is changed from ASCII-8BIT to UTF-8 in erb
+ command. [Bug #14095]
* Carriage returns are changed to be trimmed properly if trim_mode is specified
and used. Duplicated newlines will be removed on Windows. [Bug #5339] [Bug #11464]
diff --git a/bin/erb b/bin/erb
index 6a88c3b..86f7042 100755
--- a/bin/erb
+++ b/bin/erb
@@ -122,7 +122,7 @@ EOU
exit 1
end
- $<.set_encoding(Encoding::ASCII_8BIT, nil)
+ $<.set_encoding(Encoding::UTF_8, nil)
src = $<.read
filename = $FILENAME
exit 2 unless src
diff --git a/test/erb/test_erb_command.rb b/test/erb/test_erb_command.rb
index 406b14c..7e2b874 100644
--- a/test/erb/test_erb_command.rb
+++ b/test/erb/test_erb_command.rb
@@ -9,4 +9,10 @@ class TestErbCommand < Test::Unit::TestCase
"var=hoge"],
"<%=var%>", ["hoge"])
end
+
+ def test_template_file_encoding
+ assert_in_out_err(["-w",
+ File.expand_path("../../../bin/erb", __FILE__)],
+ "<%=''.encoding.to_s%>", ["UTF-8"])
+ end
end