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

compile_file does not allow to pass a specific encoding #1965

Closed
mgreter opened this issue Jan 12, 2016 · 4 comments
Closed

compile_file does not allow to pass a specific encoding #1965

mgreter opened this issue Jan 12, 2016 · 4 comments
Labels
help wanted Extra attention is needed infrastructure Non-spec task or chore planned We would like to add this feature at some point

Comments

@mgreter
Copy link

mgreter commented Jan 12, 2016

To be clear, I'm talking about input encoding, output is always utf-8.

Maybe I'm missing something, but I couldn't figure out how to define a specific encoding for input files if they lack any bom or charset declaration. Therefore ruby sass will probably apply the default encoding, which would be CP850 in my case. But I know that the file in question is utf-8, so I would expect:

Sass.compile_file(filename, :encoding => "UTF-8")

Btw. I find it quite puzzeling that it also seems impossible in ruby to open a file in utf-8 encoding with the newline conversion disabled. We have some spec tests results that contain single \r chars, which get converted to \n by ruby io if newline conversion is on. But I'm using 1.9.3, so that may already be solved (saw a writebin function in the docs). I can work around those issues, but I figured I still post this here.

@mgreter
Copy link
Author

mgreter commented Jan 12, 2016

OK, found out how to do it, since cli had an option for exactly this:

Encoding.default_external = "UTF-8"
Sass.compile_file(filename)

Not sure if it would be worth adding a default_encoding option for the file compiler though.

@mgreter mgreter closed this as completed Jan 12, 2016
@chriseppstein
Copy link

That's an oversight. The encoding should be specifiable as an option. Ruby's file API allows a per-file-read specification of the encoding. Setting default_external globally is a workaround that works ok for things like the Sass executable, but should not be forced onto other processes.

@chriseppstein chriseppstein reopened this Jan 12, 2016
@chriseppstein chriseppstein added planned We would like to add this feature at some point infrastructure Non-spec task or chore help wanted Extra attention is needed labels Jan 12, 2016
@MareoRaft
Copy link

How can I find the most easy "Help Wanted" issues? I'm new but would like to contribute.

@nex3
Copy link
Contributor

nex3 commented Apr 6, 2018

I'm moving this issue to the new Ruby Sass repository because it's specific to Ruby Sass's implementation. Once it's there, I'm going to close it as "on ice" because Ruby Sass is deprecated and no additional features are planned for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed infrastructure Non-spec task or chore planned We would like to add this feature at some point
Projects
None yet
Development

No branches or pull requests

4 participants