From 06583f137b5a0ee53275e498c40e5d95ac0a819e Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 7 Aug 2010 20:30:49 +0200 Subject: Change readfile() to ignore byte order marks, unless in binary mode. --- src/eval.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/eval.c') diff --git a/src/eval.c b/src/eval.c index 8a26b6690..5dfb7f226 100644 --- a/src/eval.c +++ b/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; -- cgit v1.2.1