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:
14
src/eval.c
14
src/eval.c
@@ -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;
|
||||
|
Reference in New Issue
Block a user