.
D 2002-02-28T18:39:42
J assignee nijtmans
J cmimetype text/plain
J comment Tcl\s8.3.4\sdoes\snot\sdecode\siso-2022-jp\sdata\sproperly\s\nunder\scertain\sconditions.\n\nAttached\sis\sa\sfile\s"iso2022.sample".\s\sThis\sfile\sis\s\nalso\slocated\sat\nhttp://www.nevernever.org/iso2022.sample\n\nWhen\sthis\sfile\sis\sread\sline-by-line\susing\s"gets",\sonly\s\nthe\sfirst\s62\sbytes\sof\seach\sline\sare\sdecoded\sproperly.\s\s\nThe\sremainder\sof\sthe\sline\sis\sdecoded\sas\srubbish,\seg.\sa\s\nstring\sliteral\ssuch\sas:\n\n%e%"%&%H$N:]$N\n\n\nA\ssample\sof\sthe\sgarbled\soutput\s(reencoded\sin\siso-2022-\njp)\scan\sbe\sfound\sat\nhttp://www.nevernever.org/iso2022.out\n\n\nHere\sis\sa\scode\ssegment\swhich\swill\sproduce\soutput\swith\s\nmangled\slines\sin\s$msg:\n\n\s\s\s\sset\sf\s[\sopen\s$filename\sr\s]\n\s\s\s\sfconfigure\s$f\s-encoding\siso2022-jp\n\s\s\s\sset\smsg\s""\n\n\s\s\s\swhile\s{\s![eof\s$f]\s}\s{\n\s\s\s\s\sset\sline\s[\sgets\s$f\s]\n\s\s\s\s\sappend\smsg\s"$line\\n"\n\s\s\s\s}\n\n\s\s\s\sclose\s$f\n\n\nInterestingly,\sthis\sproblem\sis\snot\sexhibited\swhen\sthe\s\nfile\sis\sread\susing\s"read",\sas\sin:\n\n\s\s\sset\sf\s[\sopen\s$filename\sr\s]\n\s\s\sfconfigure\s$f\s-encoding\siso2022-jp\n\s\s\sset\smsg\s[\sread\s$f\s]\n\s\s\sclose\s$f\n\n\n\n\nA\sUsenet\sthread\sdiscussing\sthis\sissue\s(subject\s\nwas\s"trouble\sdecoding\siso2022-jp")\scan\sbe\sfound\sat\s\nhttp://groups.google.com/groups?\nhl=en&frame=right&th=b7c438757333dab2\n\nJeff\sHobbs\sposted:\s"OK,\son\sthis\sone\sThomas\skeyed\sme\sin\s\nby\spointing\sout\sthat\sonly\shis\sstrict\sexample\sfails\s\n(using\sgets\s-\sread\sis\sOK).\s\sSo\sI\shoned\sin\son\sthat,\sand\s\nwas\sfurther\skeyed\sin\sthat\she\snoted\sonly\sX\schars\sever\s\nget\stranslated.\s\sPoking\saround,\sI\sfound\sthe\sproblem\s\nin\s\stclIO.c:FilterInputBytes.\s\sIt\shas\ssomething\sto\sdo\s\nwith\sthe\svalue\sof\sthe\sENCODING_LINESIZE\s#define\s\n(currently\s30).\s\sIf\sI\sbump\sthat\sup\sto\s60,\sI\scan\sread\s\nThomas'\ssample\sjust\sfine,\sand\sif\sI\sdrop\sit\sto\s20,\sit\s\nstops\sthe\scorrect\sencoding\stranslation\seven\searlier\s\nper\sline.\s\sThat's\sobviously\snot\sa\scorrect\sfix,\sbut\sit\s\ndoes\sindicate\sthat\sFilterInputBytes\sisn't\sencoding\s\nright.\s\sI'll\shave\sto\slook\sinto\sthis\smore\swhen\sit's\snot\s\npast\smidnight\s..."\n\n\n\n
J foundin obsolete:\s8.3.4
J priority 5\sMedium
J resolution None
J status Open
J submitter atfrost
J subsystem 44.\sUTF-8\sStrings
J title Decoding\sbroken\sfor\siso-2022-jp
J type Bug
K 523988ffffffffffffffffffffffffffffffffff
U atfrost
Z 241d347e9e4944436a4733490038e163