Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoding::CompatibilityError with ruby 1.9.3p0 on windows #152

Closed
scriptfans opened this issue Jul 5, 2012 · 3 comments
Closed

Encoding::CompatibilityError with ruby 1.9.3p0 on windows #152

scriptfans opened this issue Jul 5, 2012 · 3 comments
Milestone

Comments

@scriptfans
Copy link

I use Tilt to handle my erb template which contain some chinese characters, But it was wrong:

Encoding::CompatibilityError in Servicdev::NodesController#show

incompatible character encodings: ASCII-8BIT and UTF-8

my ruby code is:

path = Rails.root.join('templates', "test.erb").to_s template = Tilt.new path template.render

and the test.erb's content is:

<%# 中文注释 %> <tag name="测试" />

I found the template.data.encoding is incorrect (ASCII-8BIT), So I can solve the problem by change the ruby code to:

path = Rails.root.join('templates', "test.erb").to_s template = Tilt.new path template.instance_variable_set(:@default_encoding, 'utf-8') template.render

But is that correct? will have any side effects? I'm not sure. I think this is a Tilt's bug

@judofyr
Copy link
Collaborator

judofyr commented Jul 31, 2012

Can you try the encodings-branch here and see if that solves the problem?

@vcastellm
Copy link

I found this issue using serve (get-serve.com), encodings branch solved the problem. Would be great to see this in the next release.

@judofyr
Copy link
Collaborator

judofyr commented Mar 24, 2013

In the latest version of Tilt (1.3.6) you should be able to override the encoding like this:

Tilt.new(path, :default_encoding => 'utf-8')

We're aiming for merging in #175 soon. See the documentation in that pull request for how it will work in the future.

(I'm closing this now since it's been a while. Please re-open this if you need more help for with a workaround for current Tilt. Chime in on #175 if you have concerns about the upcoming encoding support.)

@judofyr judofyr closed this as completed Mar 24, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants