summaryrefslogtreecommitdiffstats
path: root/src/mbyte.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbyte.c')
-rw-r--r--src/mbyte.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/mbyte.c b/src/mbyte.c
index 89b53c2e5a..695b651bb5 100644
--- a/src/mbyte.c
+++ b/src/mbyte.c
@@ -990,6 +990,10 @@ dbcs_char2bytes(c, buf)
{
buf[0] = (unsigned)c >> 8;
buf[1] = c;
+ /* Never use a NUL byte, it causes lots of trouble. It's an invalid
+ * character anyway. */
+ if (buf[1] == NUL)
+ buf[1] = '\n';
return 2;
}
buf[0] = c;
@@ -3087,7 +3091,14 @@ iconv_string(vcp, str, slen, unconvlenp)
*to++ = '?';
if ((*mb_ptr2cells)((char_u *)from) > 1)
*to++ = '?';
- l = (*mb_ptr2len_check)((char_u *)from);
+ if (enc_utf8)
+ l = utfc_ptr2len_check_len((char_u *)from, fromlen);
+ else
+ {
+ l = (*mb_ptr2len_check)((char_u *)from);
+ if (l > fromlen)
+ l = fromlen;
+ }
from += l;
fromlen -= l;
}