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

7 views
Skip to first unread message

h_east

unread,
Jan 17, 2026, 10:17:17 AM (6 days ago) Jan 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 AM (5 days ago) Jan 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 AM (4 days ago) Jan 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 AM (yesterday) Jan 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 AM (yesterday) Jan 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>

Reply all
Reply to author
Forward
0 new messages