From fe4f32e06fcbadbf80540807a4033448b826dfe8 Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Sun, 24 Sep 2023 10:28:55 -0500 Subject: [PATCH] Parser::SourceParser#convert_encoding - fixup BOM encoding --- lib/yard/parser/source_parser.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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