rouge-ruby/rouge · error · EncodingError
Bad encoding: #{str.encoding.names.join(',')}. Please conver
Error message
Bad encoding: #{str.encoding.names.join(',')}. Please convert your string to UTF-8. What it means
Error "Bad encoding: #{str.encoding.names.join(',')}. Please convert your string to UTF-8." thrown in rouge-ruby/rouge.
Source
Thrown at lib/rouge/lexer.rb:328
(@filenames ||= []).concat(fnames)
end
# Specify a list of mimetypes associated with this lexer.
#
# @example
# class Html < Lexer
# mimetypes 'text/html', 'application/xhtml+xml'
# end
def mimetypes(*mts)
(@mimetypes ||= []).concat(mts)
end
# @private
def assert_utf8!(str)
encoding = str.encoding
return if encoding == Encoding::US_ASCII || encoding == Encoding::UTF_8 || encoding == Encoding::BINARY
raise EncodingError.new(
"Bad encoding: #{str.encoding.names.join(',')}. " +
"Please convert your string to UTF-8."
)
end
private
def registry
@registry ||= {}
end
end
# -*- instance methods -*- #
attr_reader :options
# Create a new lexer with the given options. Individual lexers may
# specify extra options. The only current globally accepted option
# is `:debug`.
#View on GitHub (pinned to bd7dad7b09)
When it happens
Trigger: Thrown at lib/rouge/lexer.rb:328 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of rouge-ruby/rouge@bd7dad7b09 (2026-08-23).
Data as JSON: /api/errors/e925d86f2e644cdb.
Report an issue: GitHub.