<i>Tcl 9: eof errorneously flagged with not reported encoding read error</i> status still Open with 3 other changes
by
.
D 2022-12-09T15:07:56.822
J icomment >\sIsn't\sthis\sa\sbit\sawkwarded\s/\sconvoluted?\sEspecially\sgiven\sthat\smost\sprogrammers\sare\stypically\sdon't\sexpect\sto\shave\sto\scheck\s[eof]\sif\sthey\swant\sto\sread\sthe\swhole\sdata\sout\sof\sa\sfile\sin\sone\sgo\swith\s[read\s$fd].\r\n\r\nIndeed,\sin\sTcl\s8.x,\sdoing\sa\s[read\s$fd]\sget\sthe\swhole\scontent\sof\sthe\sfile\s(unless\susing\s-eofchar,\sthen\severything\safter\sthe\seofchar\sis\sstripped).\sThat\s-\sindeed\s-\sshould\sstay\sin\sTcl\s9.0.\sThe\sreason\sthat\sit\ssucceeds\salways,\sis\sthat\sthere\sis\sno\serror-reporting\sfor\sencoding\serrors.\sFor\sutf-8,\s\\x81\sis\san\sinvalid\sbyte\ssequence,\sbut\sit\swill\ssilently\sbe\shandled\sas\sif\sit\swas\s\\xC2\\x01,\sassuming\siso-8859-1\sin\sstead\sof\sutf-8\sas\sfallback.\r\n\r\nWhen\s-strictencoding\sis\sspecified,\s[read]\sis\sno\slonger\sguaranteed\sto\sread\sthe\swhole\sfile.\sIt\swill\sread\suntil\sEOF,\sor\suntil\sthe\seofchar\sor\suntil\san\sencoding\serror\sis\sencountered.\s[eof]\scan\sbe\sused\sto\smake\sthe\sdistinction,\sand\sa\sfurther\s[read]\swill\sthrow\san\sexception.\sIt's\sup\sto\sthe\suser\show\sto\shandle\sthis.\sOne\spossibility\swould\sbe\sto\schange\sthe\sencoding\sof\sthe\schannel,\sand\sdo\sanother\sread.\r\n\r\nSo,\syes,\sI\sthink\sthis\sis\show\sI\swould\sexpect\sit\sto\swork.\sIn\sshort:\sIf\syou\sare\snot\sprepared\sto\shandle\serrors,\sdon't\suse\s-strictencoding.\r\n\r\nThank\syou\sfor\sthis\sreport\sand\sthe\stest-case!\sWhenever\s[eof]\sreturns\strue,\sany\sfollow-up\s[read]\sshould\sreturn\sthe\sempty\sstring\s(or\sreturn\smore\sdata\sif\sit\sbecame\savailble\sin\sthe\smeantime).\sThat's\san\sassumption\sfrom\sTcl\s8.x\sthat\sI\swould\slike\sto\skeep\sin\s9.0.\sIn\syour\sexample,\sthat\swas\sviolated,\swhich\smeans\sthat\sI\s-\sindeed\s-\sconsider\sthis\sa\sreal\sbug\s(which\s-\shopefully\s-\sis\sfixed\swith\sthis\schange)
J login jan.nijtmans
J mimetype text/x-fossil-wiki
K b8f575aa2398b0e44b5a037326b9d75037e2da4a
U jan.nijtmans
Z 046af2376dd447e502c21d415c3cc4aa