result = STRLEN(eap->arg) + 2;
for (p = eap->arg; *p; ++p)
{
- if (*p == '\\' || *p == '"')
+#ifdef FEAT_MBYTE
+ if (enc_dbcs != 0 && (*mb_ptr2len)(p) == 2)
+ /* DBCS can contain \ in a trail byte, skip the
+ * double-byte character. */
+ ++p;
+ else
+#endif
+ if (*p == '\\' || *p == '"')
++result;
}
*buf++ = '"';
for (p = eap->arg; *p; ++p)
{
- if (*p == '\\' || *p == '"')
+#ifdef FEAT_MBYTE
+ if (enc_dbcs != 0 && (*mb_ptr2len)(p) == 2)
+ /* DBCS can contain \ in a trail byte, copy the
+ * double-byte character to avoid escaping. */
+ *buf++ = *p++;
+ else
+#endif
+ if (*p == '\\' || *p == '"')
*buf++ = '\\';
*buf++ = *p;
}