int count = 0;
int i;
int allocated = FALSE;
+#ifdef FEAT_MBYTE
+ char_u *sconv;
+ int converted;
+#endif
while (*p == ',')
{
if (!allocated)
{
for (i = 0; i < count; ++i)
- if (values[i].bv_type == BVAL_STRING)
+ if (values[i].bv_type == BVAL_STRING
+ && !values[i].bv_allocated)
{
values[i].bv_string = vim_strnsave(
values[i].bv_string, values[i].bv_len);
}
s[len] = NUL;
+#ifdef FEAT_MBYTE
+ converted = FALSE;
+ if (virp->vir_conv.vc_type != CONV_NONE && *s != NUL)
+ {
+ sconv = string_convert(&virp->vir_conv, s, NULL);
+ if (sconv != NULL)
+ {
+ if (s == buf)
+ vim_free(s);
+ s = sconv;
+ buf = s;
+ converted = TRUE;
+ }
+ }
+#endif
+ /* Need to copy in allocated memory if the string wasn't allocated
+ * above and we did allocate before, thus vir_line may change. */
if (s != buf && allocated)
s = vim_strsave(s);
values[count].bv_string = s;
values[count].bv_type = BVAL_STRING;
values[count].bv_len = len;
- values[count].bv_allocated = allocated;
+ values[count].bv_allocated = allocated
+#ifdef FEAT_MBYTE
+ || converted
+#endif
+ ;
++count;
if (nextp != NULL)
{
call delete('Xviminfo')
endfunc
+
+func Test_viminfo_encoding()
+ if !has('multi_byte')
+ return
+ endif
+ set enc=latin1
+ call histdel(':')
+ call histadd(':', "echo '\xe9'")
+ wviminfo Xviminfo
+
+ set fencs=utf-8,latin1
+ set enc=utf-8
+ sp Xviminfo
+ call assert_equal('latin1', &fenc)
+ close
+
+ call histdel(':')
+ rviminfo Xviminfo
+ call assert_equal("echo 'é'", histget(':', -1))
+
+ call delete('Xviminfo')
+endfunc