encoding of page fragments turn into "US-ASCII"
Reported by Tomoaki Hayasaka | September 29th, 2010 @ 03:32 AM | in Hobo 1.3 (Rails 3)
I use Hobo 1.3pre7 + Rails 3.0 + Ruby 1.9.2.
Dryml strips encoding out from erb source, and this causes side effects:
-
<%= some_utf8_string.encoding %> produces "ASCII-8BIT".
-
<%= helper_function_that_returns_utf8_string %> causes "incompatible character encodings: UTF-8 and ASCII-8BIT". This is grave.
Here's a fix:
diff --git a/dryml/lib/dryml/dryml_builder.rb b/dryml/lib/dryml/dryml_builder.rb
index 79468fc..269f38e 100644
--- a/dryml/lib/dryml/dryml_builder.rb
+++ b/dryml/lib/dryml/dryml_builder.rb
@@ -61,7 +61,11 @@ module Dryml
def erb_process(erb_src)
trim_mode = ActionView::TemplateHandlers::ERB.erb_trim_mode
erb = ERB.new(erb_src, nil, trim_mode, "output_buffer")
- erb.src.split(';')[1..-2].join(';')
+ res = erb.src.split(';')[1..-2].join(';')
+ if res.respond_to? :force_encoding
+ res.force_encoding(erb_src.encoding)
+ end
+ res
end
def build(local_names, auto_taglibs, src_mtime)
Comments and changes to this ticket
-
Domizio Demichelis September 29th, 2010 @ 10:53 PM
- State changed from new to resolved
- Milestone set to Hobo 1.3 (Rails 3)
- Assigned user set to Domizio Demichelis
- Milestone order changed from 197900 to 0
applied in 6438e273
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »