Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Error reading fixed number of characters from UTF16-LE file containing non-BMP chars

Closed / Fixedf2e924e88181d602cb3b558afba3dc2995ea11a6Created 2 years agoUpdated 2 years ago
Descriptionmarkdown2024-08-20 05:37:13

The following writes emoji to a file in UTF16LE and reads the file back successfully. However, reads of a specific number of characters fails.

% set fd [open utf16.txt wb]
file26c91f9a4c0
% puts -nonewline $fd [encoding convertto utf-16le A\U1F600]
% close $fd
% set fd [open utf16.txt]; fconfigure $fd -encoding utf-16le
% read $fd
A😀
% close $fd
% set fd [open utf16.txt]; fconfigure $fd -encoding utf-16le
% read $fd 2
error reading "file26c937c7370": invalid or incomplete multibyte or wide character
% close $fd

Note the full file read succeeds but the read of two chars fails.

Marked as important because UTF-16LE is native to Win32 API.

Referenced by3
apnadkarniplain2024-08-23 08:35:56
Fixed in [df6a7e1b38].
Log in (anonymous is fine) to add a comment.