[vim/vim] blob2str() gives strange results when encoding is 'utf-16le' (Issue #19198)

9 views
Skip to first unread message

h_east

unread,
Jan 17, 2026, 10:17:17 AMJan 17
to vim/vim, Subscribed
h-east created an issue (vim/vim#19198)

Steps to reproduce

:echo blob2str(0z480065006C006C006F00, #{encoding: 'utf-16le'})
['H
e
l
l
o
']

Expected behaviour

['Hello']

Version of Vim

9.1.2089

Environment

Ubuntu 24.04.3

Logs and stack traces


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/19198@github.com>

h_east

unread,
Jan 18, 2026, 7:13:00 AMJan 18
to vim/vim, Subscribed
h-east left a comment (vim/vim#19198)

From h blob2str()

	Each <NL> byte in the blob is interpreted as the end of a
	string and a new list item is added.  Each <NUL> byte in the
	blob is converted into a <NL> character.

What!?
I think 0z4800 is the correct character code for H in 'utf-16le'...


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/19198/3765226789@github.com>

Yegappan Lakshmanan

unread,
Jan 19, 2026, 12:32:31 AMJan 19
to vim/vim, Subscribed
yegappan left a comment (vim/vim#19198)

@h-east This is a bug. The current implementation of blob2str() and str2blob() doesn't handle these encodings correctly.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/19198/3766474980@github.com>

karan yadav

unread,
Jan 22, 2026, 7:20:01 AMJan 22
to vim/vim, Subscribed
karan68 left a comment (vim/vim#19198)

working on this bug


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/19198/3784098102@github.com>

mattn

unread,
Jan 22, 2026, 10:27:47 AMJan 22
to vim/vim, Subscribed
mattn left a comment (vim/vim#19198)

This bug is troublesome. enc_canonize drops endianness information, convert_setup_ext incorrectly handles UTF-16 and UTF-8, and f_blob2str fails to append the two-byte NUL for UTF-16. (I already have a patch for this)


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/19198/3785004519@github.com>

h_east

unread,
Jan 24, 2026, 7:57:24 AMJan 24
to vim/vim, Subscribed
h-east left a comment (vim/vim#19198)

@mattn
Is this FUD? That's not like you.
If not, please submit a PR or paste a patch.
Or comment with an update on your situation.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/19198/3794588069@github.com>

mattn

unread,
Jan 24, 2026, 8:28:12 AMJan 24
to vim/vim, Subscribed
mattn left a comment (vim/vim#19198)

This is not FUD. I simply stepped back because someone else offered a fix first. You can close my PR.

#19246


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/19198/3794630715@github.com>

h_east

unread,
Jan 24, 2026, 8:50:06 AMJan 24
to vim/vim, Subscribed
h-east left a comment (vim/vim#19198)

@mattn Thanks for addressing this issue 👍


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/19198/3794666860@github.com>

mattn

unread,
Jan 24, 2026, 8:59:00 AMJan 24
to vim/vim, Subscribed
mattn left a comment (vim/vim#19198)

🙆‍♂️


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/19198/3794688466@github.com>

Christian Brabandt

unread,
Jan 31, 2026, 11:00:55 AMJan 31
to vim/vim, Subscribed

Closed #19198 as completed via 2b184d4.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issue/19198/issue_event/22430338641@github.com>

Reply all
Reply to author
Forward
0 new messages