SyntaxError for files with wrong encoding
I have multiple files that just look fine with editors (gedit, sublime, vim) but produce the following error message when loaded by Psych:
Psych.safe_load(file)
/usr/local/lib/ruby/3.0.0/psych.rb:456:in `parse': (<unknown>): invalid trailing UTF-8 octet at line 1 column 1 (Psych::SyntaxError)
A file example can be found here (renamed as attaching a .yaml file is not supported). I am not that familiar with character encoding, but the file seems to get interpreted as UTF-8 while it actually isn't. isutf8 returns metal_copper (1).yaml: line 87, char 12, byte 1497: After a first byte between E1 and EC, expecting the 2nd byte between 80 and BF. on the file example.
I do not know how editor software today handle this topic, but it sure would be desirable to have Psych parse files in the way as shown in common editors. From googling the error message it seems I am not the only one who had problems with that and it seem to produce problem now and then for users/project that use Psych.