Haml: Sass compile failing on Unicode character

Created on 17 Sep 2010  ·  16Comments  ·  Source: haml/haml

System: FreeBSD 8.1-RELEASE AMD64-GENERIC
Ruby: rvm installed 1.9.2p0 (2010-08-18 revision 29036) [x86_64-freebsd8.1]
haml/sass: gem version 3.0.18 (Classy Cassidy)

Using the Compass gem version 0.10.5 with the susy plugin, whenever I go to compile a susy-based compass project my compiled CSS shows a stack trace indicating the following:

Syntax error: Invalid US-ASCII character "\xE2"                                 
        on line 19 of /home/admin/.rvm/gems/ruby-1.9.2-p0/gems/compass-0.10. /frameworks/compass/stylesheets/compass/css3/_font-face.scss

This file contains a mixin which generates a font-face rule using Paul Irish's smiley hack for local font file overrides, as defined here: http://paulirish.com/2009/bulletproof-font-face-implementation-syntax/#smiley

Most helpful comment

@geoidesic you have to modify your .bashrc or .profile (maybe .zshrc if you use ZSH).

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

All 16 comments

Does this happen when you use Sass stand-alone?

Running the following command produces the same error:

sass -c /home/admin/.rvm/gems/ruby-1.9.2-p0/gems/compass-0.10.5/frameworks/compass/stylesheets/compass/css3/_font-face.scss

If there's another way I should run sass stand-alone, or if there's anything else I can do to help debug, let me know.

Can you provide a minimal stylesheet that displays the error?

Sure, here you go:

@mixin foo {
    src: local("☺");
}

@include foo

Running sass stand-alone on a file with that content produces the same error:

Syntax error: Invalid US-ASCII character "\xE2"
    on line 2 of bad_unicode.scss

I can't reproduce this with your minimal stylesheet. This suggests that there may be a configuration difference between our machines. If you run irb and type Encoding.default_internal, what does it print? What about Encoding.default_external?

Serendipity. I'd just followed a rabbit-trail of various Ruby 1.9 posts to that same question myself a few minutes ago. My system is showing default external is US-ASCII and internal is nil. No idea why it's US-ASCII, my system should be UTF-8.

In any case, I just set the LANG env variable to en_US.UTF-8 and it works fine.

In that case, I'll close this issue.

If anyone finds this later, remember to either set Encoding.default_external or use @charset in your Sass file.

I am also running into this problem. Can someone tell me the exact command I should use or the file and location of the file to edit to fix this? I running Ubuntu 10.04

Thanks

Conveniently, the Ubuntu documentation on setting environment variables uses the LANG variable as an example: https://help.ubuntu.com/community/EnvironmentVariables

Setting that variable to the appropriate value should do the trick.

Thank you, I will give that a shot.

I just added @charset: "UTF-8" to my stylesheet partial and it compiles successfully, but I got “ instead of . What the hell?
And adding @charset: "UTF-8" is not a better way to solve this problem. I tried to add this string to my index stylesheet but with no luck. Hey, we are in 2014 and all the world uses many languages, but in the software this problem still exists. Sad.

I wish someone would say how they changed LANG=en_US.UTF-8 instead of just saying that they did it.

@geoidesic you have to modify your .bashrc or .profile (maybe .zshrc if you use ZSH).

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

I get this error using sass & assetic, with symfony ("Error: Invalid US-ASCII character "\xEF"").

I'll add that setting LANG alone didn't help, and I had to set LC_ALL, as mentioned by Grawl above, as well.

For the record, it's not @charset: "UTF-8" in CSS - it's actually typed without quotation marks, @charset UTF-8;

What helped me was locale-gen en_US.UTF-8 && export LANG=en_US.UTF-8. My encoding kept breaking if at least one of these commands is omitted.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dewski picture dewski  ·  8Comments

Arcovion picture Arcovion  ·  11Comments

pib picture pib  ·  4Comments

mattwildig picture mattwildig  ·  9Comments

k0kubun picture k0kubun  ·  13Comments