Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/css_parser/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ def ignore_pattern(css, regex, options)
# Returns a string.
def cleanup_block(block, options = {}) # :nodoc:
# Strip CSS comments
utf8_block = block.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: ' ')
utf8_block = block.encode('UTF-8', 'UTF-8', invalid: :replace, undef: :replace, replace: ' ')
utf8_block = ignore_pattern(utf8_block, STRIP_CSS_COMMENTS_RX, options)

# Strip HTML comments - they shouldn't really be in here but
Expand Down
10 changes: 10 additions & 0 deletions test/test_css_parser_misc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ def setup
@cp = Parser.new
end

def test_utf8
css = <<-CSS
.chinese { font-family: "Microsoft YaHei","微软雅黑"; }
CSS

@cp.add_block!(css)

assert_equal 'font-family: "Microsoft YaHei","微软雅黑";', @cp.find_by_selector('.chinese').join(' ')
end

def test_at_page_rule
# from http://www.w3.org/TR/CSS21/page.html#page-selectors
css = <<-CSS
Expand Down