Skip to content

Commit

Permalink
Parser::SourceParser#convert_encoding - fixup BOM encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
MSP-Greg committed Sep 24, 2023
1 parent 522e12e commit ae69ade
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/yard/parser/source_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(/\A#{bom}/, '').force_encoding(encoding)
end
end
content.force_encoding('utf-8') # UTF-8 is default encoding
Expand Down

0 comments on commit ae69ade

Please sign in to comment.