Skip to content

Commit

Permalink
Merge pull request #1510 from MSP-Greg/00-ruby3.3-bom
Browse files Browse the repository at this point in the history
Parser::SourceParser#convert_encoding - fixup BOM encoding
  • Loading branch information
lsegal authored Sep 30, 2023
2 parents a3b9c37 + fe4f32e commit abcba4b
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(bom, '').force_encoding(encoding)
end
end
content.force_encoding('utf-8') # UTF-8 is default encoding
Expand Down

0 comments on commit abcba4b

Please sign in to comment.