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
6711cc9484Merge [df6a7e1b38bfae63]: Fix [33f9b4de51], [945d2387d7], [f2e924e881] - encoding character limit bugs. check-in2024-08-31 07:38:40df6a7e1b38Fix [33f9b4de51], [945d2387d7], [f2e924e881] - encoding character limit bugs check-in2024-08-23 08:32:29c19b624fa9Proposed fixes for [945d2387d7], [f2e924e881], [33f9b4de51] check-in2024-08-22 18:12:15
apnadkarniplain2024-08-23 08:35:56
Fixed in [df6a7e1b38].
Log in (anonymous is fine) to add a comment.