Encoding::CompatibilityError with UTF-8 encoded ERB template
------------------------------------------------------------
Key: JRUBY-5763
URL: http://jira.codehaus.org/browse/JRUBY-5763
Project: JRuby
Issue Type: Bug
Components: Ruby 1.9.2, Standard Library
Affects Versions: JRuby 1.6.1
Reporter: Clemens Fuchslocher
Assignee: Thomas E Enebo
Attachments: erb_utf8.tar.gz
Using an UTF-8 encoded ERB template with JRuby 1.6.1 in 1.9 mode gives an
Encoding::CompatibilityError.
See the attached testcase [^erb_utf8.tar.gz].
With Ruby 1.9.2:
{noformat}
$ ruby --version
ruby 1.9.2p180 (2011-02-18 revision 30909) [i686-linux]
$ ruby erb_utf8.rb
result.encoding == UTF-8
__ENCODING__ == UTF-8
@text == äöüÄÖÜ
äöüÄÖÜ
{noformat}
With JRuby 1.6.1 in 1.9 mode:
{noformat}
$ jruby --1.9 --version
jruby 1.6.1 (ruby-1.9.2-p136) (2011-04-12 85838f6) (Java HotSpot(TM) Client VM
1.6.0_24) [linux-i386-java]
$ jruby --1.9 -e "require 'java'; p
java.lang.System.getProperty('file.encoding');"
"UTF-8"
$ jruby --1.9 erb_utf8.rb
Encoding::CompatibilityError: incompatible character encodings: UTF-8 and
ASCII-8BIT
concat at org/jruby/RubyString.java:2430
result at (erb):3
eval at org/jruby/RubyKernel.java:1093
result at /opt/jruby-1.6/lib/ruby/1.9/erb.rb:753
(root) at erb_utf8.rb:19
{noformat}
Removing all UTF-8 encoded characters from the ERB template gives the following
result:
{noformat}
$ cat erb_utf8.erb
<%#encoding: utf-8 %>
__ENCODING__ == <%= __ENCODING__ %>
@text == <%= @text %>
$ jruby --1.9 erb_utf8.rb
result.encoding == US-ASCII
__ENCODING__ == US-ASCII
@text == äöüÄÖÜ
{noformat}
US-ASCII?
Is the character encoding of the magic comment ignored?
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email