diff src/eval.c @ 8993:2085167ab1b0 v7.4.1782

commit https://github.com/vim/vim/commit/fca66003053f8c0da5161d1fe4b75b3a389934b5 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Apr 23 15:30:09 2016 +0200 patch 7.4.1782 Problem: strcharpart() does not work properly with some multi-byte characters. Solution: Use mb_cptr2len() instead of mb_char2len(). (Hirohito Higashi)
author Christian Brabandt <cb@256bit.org>
date Sat, 23 Apr 2016 15:45:04 +0200
parents 42e85487c0f9
children d5c6f1c5cd28
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -19764,7 +19764,7 @@ f_strcharpart(typval_T *argvars, typval_
 	if (nchar > 0)
 	    while (nchar > 0 && nbyte < slen)
 	    {
-		nbyte += mb_char2len(p[nbyte]);
+		nbyte += mb_cptr2len(p + nbyte);
 		--nchar;
 	    }
 	else
@@ -19779,7 +19779,7 @@ f_strcharpart(typval_T *argvars, typval_
 		if (off < 0)
 		    len += 1;
 		else
-		    len += mb_char2len(p[off]);
+		    len += mb_cptr2len(p + off);
 		--charlen;
 	    }
 	}