Am I doing something incorrect in the following?

haml = IO.read( layout )
template = Haml::Engine.new( haml, HAML_OPTIONS )
result = template.render
( Object.new, :contents=>contents, :page=>self, :global=>@bundle.toc )

p RUBY_VERSION, RUBY_PLATFORM,
  Encoding.default_external, Encoding.default_internal,
  haml.encoding, HAML_OPTIONS, result.encoding

"1.9.1"
"i386-mingw32"
#<Encoding:UTF-8>
#<Encoding:UTF-8>
#<Encoding:UTF-8>
{:format=>:html4, :ugly=>true, :encoding=>"UTF-8"}
#<Encoding:ASCII-8BIT>

I expected the result to have an encoding of UTF-8.

This is on Windows 7, 64-bit with Haml/Sass 2.2.16 (Powerful Penny).
The 'layout' haml file referred to above is saved in utf8 (not that it
has any non-ascii chars). Every .rb file in my project starts with the
magic comment:
# encoding: UTF-8


For the record, I can work around this by adding:
  result.encode!( 'UTF-8', :undef=>:replace )
but I'm wondering if this is a Haml bug or PEBCAK on my part.

Also for the Google record, this might cause you to hit an error such
as:
(haml):20:in `block in render': incompatible character encodings:
ASCII-8BIT and UTF-8 (Encoding::CompatibilityError)
when the result is used later in another UTF-8 Haml template.
-- 
You received this message because you are subscribed to the Google Groups 
"Haml" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/haml?hl=en.


Reply via email to