0
0
mirror of https://github.com/vim/vim.git synced 2025-09-27 04:14:06 -04:00

Change readfile() to ignore byte order marks, unless in binary mode.

This commit is contained in:
Bram Moolenaar
2010-08-07 20:30:49 +02:00
parent 1549e29af4
commit 06583f137b
4 changed files with 21 additions and 6 deletions

View File

@@ -14267,6 +14267,20 @@ f_readfile(argvars, rettv)
}
else if (buf[filtd] == NUL)
buf[filtd] = '\n';
#ifdef FEAT_MBYTE
else if (buf[filtd] == 0xef
&& enc_utf8
&& filtd + 2 < buflen
&& !binary
&& buf[filtd + 1] == 0xbb
&& buf[filtd + 2] == 0xbf)
{
/* remove utf-8 byte order mark */
mch_memmove(buf + filtd, buf + filtd + 3, buflen - filtd - 3);
--filtd;
buflen -= 3;
}
#endif
}
if (readlen <= 0)
break;