summaryrefslogtreecommitdiff
path: root/lib/erb.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/erb.rb')
-rw-r--r--lib/erb.rb9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/erb.rb b/lib/erb.rb
index e1f0782855..d48d00ac3e 100644
--- a/lib/erb.rb
+++ b/lib/erb.rb
@@ -486,10 +486,10 @@ class ERB
end
class Buffer # :nodoc:
- def initialize(compiler)
+ def initialize(compiler, enc=nil)
@compiler = compiler
@line = []
- @script = ""
+ @script = enc ? "#coding:#{enc.to_s}\n" : ""
@compiler.pre_cmd.each do |x|
push(x)
end
@@ -517,11 +517,10 @@ class ERB
end
def compile(s)
- out = Buffer.new(self)
- out.push("# -*- coding: #{s.encoding} -*-\n")
+ out = Buffer.new(self, s.encoding)
content = ''
- scanner = make_scanner(s)
+ scanner = make_scanner(s.dup.force_encoding("ASCII-8BIT"))
scanner.scan do |token|
if scanner.stag.nil?
case token