# HG changeset patch # User Markus Mützel # Date 1531570582 -7200 # Node ID 467729037209a257ef0db3d9c82b6f489bfb75b4 # Parent b3f6443f6b20daa1c16157d0985bc508388bd6e2 Strip BOM from UTF-8 encoded .m files (bug #52574). * input.cc: Strip byte order mark (BOM) from UTF-8 encoded .m files. diff -r b3f6443f6b20 -r 467729037209 libinterp/corefcn/input.cc --- a/libinterp/corefcn/input.cc Fri Jul 13 21:46:50 2018 -0700 +++ b/libinterp/corefcn/input.cc Sat Jul 14 14:16:22 2018 +0200 @@ -1115,7 +1115,13 @@ = (mfile_encoding.compare ("system") == 0 ? octave_locale_charset_wrapper () : mfile_encoding); - if (encoding.compare ("utf-8") != 0) + if (encoding.compare ("utf-8") == 0) + { + // Check for BOM and strip it + if (src_str.compare (0, 3, "\xef\xbb\xbf") == 0) + src_str.erase (0, 3); + } + else { // convert encoding to UTF-8 before returning string const char *src = src_str.c_str ();