diff options
author | Bram Moolenaar <Bram@vim.org> | 2010-08-07 20:30:49 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2010-08-07 20:30:49 +0200 |
commit | 06583f137b5a0ee53275e498c40e5d95ac0a819e (patch) | |
tree | eec875e58201dbc26ebd0b8f52939b10ca14fef8 /src/eval.c | |
parent | 1549e29af4159583ae5f3991f733ba3dfd97a22c (diff) | |
download | vim-git-06583f137b5a0ee53275e498c40e5d95ac0a819e.tar.gz |
Change readfile() to ignore byte order marks, unless in binary mode.
Diffstat (limited to 'src/eval.c')
-rw-r--r-- | src/eval.c | 14 |
1 files changed, 14 insertions, 0 deletions
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; |