D 2023-02-23T15:22:41.384
J icomment From\s[Ashok's\sdocument](https://www.magicsplat.com/tcl9/tcl9unicode.html):\r\n\r\n_6.5.2\sChannel\sread\sstate\safter\serrors_\r\n\r\nRelated\sto\sthe\sabove\sis\sthe\squestion\sof\sthe\schannel\sstate\swhen\san\sexception\sis\sraised\son\sa\sread\sor\sgets\sdue\sto\sinvalid\sinput\sbytes.\r\n\r\nMy\sopinion\sis\sthat\swhen\san\sexception\sis\sraised,\sthe\sread\sposition\sshould\snot\sbe\schanged\sfrom\sthe\svalue\sat\sthe\stime\sthe\sread\sor\sgets\swas\sinvoked.\sThis\sallows\sthe\sapplication\sto\sthen\sturn\soff\sthe\sstrict\schecking\s(if\sso\sdesired)\sand\sread\sin\sthe\srest\sof\sthe\sdata.\sFor\sexample,\r\n\r\n<pre>\r\n%\sset\sfd\s[open\sx.txt\sr]\r\nfile1de34c88158\r\n%\sfconfigure\s$fd\s-encoding\sutf-8\s-strictencoding\s1\r\n%\sgets\s$fd\r\na\r\n%\sgets\s$fd\r\nerror\sreading\s"file1de34c88158":\sillegal\sbyte\ssequence\r\n%\sfconfigure\s$fd\s-encoding\sutf-8\s-strictencoding\s0\r\n%\sgets\s$fd\r\nbÀ\r\n%\sgets\s$fd\r\nc\r\n</pre>\r\n\r\nAn\salternate\ssuggestion\smade\sin\sthe\smailing\slist\swas\sto\smove\sthe\sread\sposition\sto\sthe\slocation\sof\sthe\sinvalid\sbyte\sand\sreturn\sthe\scharacters\ssuccessfully\sdecoded\sso\sfar\sin\sthe\serror\soptions\sdictionary.\sMy\spersonal\sopinion\sis\sreturning\ssuccessfully\sread\sdata\sin\sthe\serror\soptions\sis\sunnatural\sand\snon-idiomatic.
J login jan.nijtmans
J mimetype text/x-markdown
K 154ed7ce564a7b4cc39463d643b251969006c247
U jan.nijtmans
Z 19829752cc5575b3ba7b6f4d8ba0c659