diff --git a/lib/yard/parser/source_parser.rb b/lib/yard/parser/source_parser.rb index 8d133e193..94749dfd9 100644 --- a/lib/yard/parser/source_parser.rb +++ b/lib/yard/parser/source_parser.rb @@ -476,9 +476,8 @@ def convert_encoding(content) content.force_encoding('binary') ENCODING_BYTE_ORDER_MARKS.each do |encoding, bom| bom.force_encoding('binary') - if content[0, bom.size] == bom - content.force_encoding(encoding) - return content + if content.start_with?(bom) + return content.sub(bom, '').force_encoding(encoding) end end content.force_encoding('utf-8') # UTF-8 is default encoding