This project is archived and is in readonly mode.

#4582 ✓resolved
Cezary Baginski

Multiple encoding support for Erubis

Reported by Cezary Baginski | May 12th, 2010 @ 01:04 PM | in 3.0.2

This just #2188 for Rails 3.0

I opened a new ticket because:

  • Ruby 1.9 encoding support in Rails is still an ongoing issue
  • Rails 3 uses Erubis, which might cause slight differences (like line numbers in errors)
  • final solution may need some discussion
  • the previous fix was only tested for Erb

I assume the solution should:

  • support templates with multiple encodings
  • support templates without magic comments as long as they match Encoding.default_internal
  • make encoding errors appear as soon as possible (before template compilation if possible)
  • set the final encoding to effectively be: (Encoding.default_internal || Encoding.default_external)
  • not try to support multibyte and ascii incompatible encodings
  • should not attempt any conversion in binary mode
  • should validate if the encoding magic matches the template
  • should avoid unnecessary calls to .encode and .dup if possible

Problems / ideas:

  • test cases for other templating engines could be provided by authors and added to Rails
  • Rails could generally disallow using multiple encodings for templates and raise errors if they don't match the current encoding
  • line numbers may need more test cases because of the way newlines are handled

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Referenced by

Pages