sass / sassc-ruby

Use libsass with Ruby!
MIT License
367 stars 156 forks source link

Set appropriate encoding for source_map #152

Closed shwaka closed 4 years ago

shwaka commented 4 years ago

Set appropriate encoding for the string @source_map of Engine, similarly to that of the string css in Engine#render.

This PR will fix the error in the last line of the following code:

# coding: utf-8
require "sassc"

template = <<EOS
body {
  // 赤
  color: red;
}
EOS
options = {
  :source_map_file => "foo.css.map",
  :source_map_contents => true
}
engine = SassC::Engine.new(template, options)
engine.render
source_map = engine.source_map
puts source_map             # includes non-ASCII character "赤"
puts source_map.encoding    # => ASCII-8BIT (UTF-8 is expected)
source_map.encode("UTF-8")  # throws Encoding::UndefinedConversionError