Hmm, the regex documentation suggests it's possible to match binary strings.  All but one test passes when using the `n` flag:

```ruby
    def decode_css_charset(str)
      str = decode_unicode_bom(str)

      if str =~ /@charset "([^"]+)"/n
        encoding = ::Encoding.find($1)
        str = str.dup
        str.force_encoding(encoding)
        len = "@charset \"#{$1}\";".encode(encoding).size
        str.slice!(0, len)
        str
      end

      # Fallback to UTF-8
      if str.encoding == ::Encoding::BINARY
        str.force_encoding(::Encoding::UTF_8)
      end

      str
    end
```