<i>Unicode support for Win32 (NT) console channels</i> status still Open with 4 other changes
by
.
D 2010-03-01T07:06:28
J icomment As\sthis\sartifact\sis\sstill\sopen,\slet\sme\sdefend\sthis\simplementation.\sMy\spurpose\sis\sto\sensure\sthat\sit\swon't\sbe\srolled\sback\sfor\s8.6\sas\swell.\n\nFirst,\s[fconfigure\sstdin\s-encoding\sutf8]\sdidn't\swork\sbefore\sthis\spatch,\sit\sjust\spretended\sto:\sutf-8\sand\sa\stypical\sconsole\scodepage\s(whatever\sit\sbe)\shave\sASCII\ssubset\sin\scommon.\sBoth\swith\sthis\spatch\sand\swithout\sit,\sthe\sconsole\schannel\safter\s[fconfigure\s...\sutf-8]\sis\smisconfigured,\si.e.\sit\scannot\sbe\sused\sto\sinput\snon-ascii\scharacters\scorrectly.\sThe\sonly\sdifference\sis\sthe\samount\sof\strouble\scaused\sby\sthis\smisconfiguration.\n\nMr.\sHobbs\sseems\sto\sexpect\sa\ssolution\sthat\snotices\sthe\supper-level\s-encoding\sreconfiguration\son\sconsole\schannel\sand\ssomehow\stakes\sit\sinto\saccount\swhen\sthe\slow-level\sI/O\sis\sdone.\sIf\sit's\sindeed\sthe\sexpected\sproperty\sof\sa\s"complete\simplementation",\sI\swould\spresent\san\sobjection:\sno\schannel\stype\sever\sworked\sthis\sway,\sbe\sit\sconsole\schannels\sor\sany\sother\schannels.\sThe\schannel\sat\sthe\slowest\slevel\sis\sa\sstream\sof\sbytes,\sand\sencoding\stranslation\sis\slayered\son\stop\sof\sit,\sbut\sit\sdoesn't\saffect\sthe\schannel\sI/O\sbehavior,\sever.\sThis\sprinciple\swas\srespected\sby\sTcl\sfrom\sthe\svery\sstart\sof\sits\sunicode\ssubsystem;\sit's\salso\swhat\sextension\sand\sapplication\sdevelopers\sdo\sexpect\sand\swill\salways\sexpect.\n\nHowever,\sthere\sis\ssometimes\sa\sreason\sfor\sthe\schannel\stype\sto\sinfluence\s_initial_\ssettings\sof\sthe\supper-level\stranslation\sprocedures:\sfor\sexample,\sTCP\ssockets\srequire\sCR-LF\sline\sendings\sfor\smost\sstandard\stext-based\snetwork\sprotocols.\sThe\ssame\sthing\sis\strue\sfor\sthe\s"unpatched"\sconsole\schannels:\sthey\spreset\sthe\sencoding\sto\san\sautodetected\scodepage\s(result\sof\sGetConsoleCP);\sbut\sthey\sdon't\stry\sto\ssynchronize\sfurther\schannel\sencoding\schanges\swith\sconsole\scodepage.\sOnce\sthe\schannel\sis\screated,\sthe\sapplication\sis\sfree\sto\sfconfigure\sit\sto\sany\sencoding\s(breaking\sthe\scorrectness\sof\stranslation,\sof\scourse);\sif\sthe\sconsole\scodepage\sis\schanged\safter\sthe\schannel\screation\s(exec\scmd\s/c\schcp...),\sthe\s"real"\slow-level\sencoding\sand\sthe\stcl\stranslation-level\sencoding\sare\sagain\sout\sof\ssync.\n\n"Patched"\simplementation\sjust\sdetects\sand\suses\s"unicode"\sas\sinitial\ssetting,\sexactly\sthe\ssame\sway\sas\sboth\simplementations\sact\son\snon-unicode\ssystems,\sdetecting\snon-unicode\scodepages.\sIt\sdoesn't\sprevent\san\sapplication\sfrom\saltering\sit,\seven\sif\sit\smakes\sthe\schannel\sunusable.\n\nTo\sbe\sshort,\sI\scould\ssay\sthat\s[fconfigure\sstdin\s-encoding\sunicode]\swill\shang\sthe\s"unpatched"\simplementation\sand\swork\swith\s"patched"\sone:\sjust\sthe\ssame\sas\sthe\sreverse\sis\strue\sfor\s-encoding\sutf-8\s(which\sfact\swas\sthe\sreason\sof\srolling\sback\sthis\spatch).\n\nThere\sis,\showever,\sone\spossible\scompromise\sthat\smay\sbe\sadded\sto\smy\simplementation\sto\srestore\sthe\sbackward\scompatibility,\smaking\sthe\schannel\snot-so-obviously-broken\safter\sencoding\smisconfiguration:\sI\scan\suse\sutf-8\sas\sthe\s"presented\slow-level"\sencoding\son\sunicode\ssystems,\sand\sdo\sthe\sutf8<->unicode\stranslation\sduring\sthe\sI/O.\sThis\sway,\sutf-8\swill\sbe\sset\sup\sas\sa\schannel\sencoding\sby\sdefault;\sif\sany\sapplication\sreconfigures\sthe\schannel\sto\sutf-8\sagain,\severything\swill\swork\s(not\sjust\spretend\sto);\sand\sif\sthe\schannel\sis\sreconfigured\sto\ssome\swrong\sencoding\sbeing\sa\ssuperset\sof\sASCII,\sthe\sthing\sat\sleast\swon't\s_hang_.\n\nHereby\sI\srequest\scomments\sfrom\sMr.\sHobbs,\sboth\sof\sthe\scurrent\sstate\sof\sthe\spatch\sand\son\sthe\sproposed\simprovement,\son\sthe\spossibility\sof\sbackporting\sit\sagain\sinto\s8.5\sand\s8.4\sonce\sthe\simprovement\sis\smade,\sand\son\sthe\splans\sfor\s8.6\s(is\sit\sacceptable\sas\sis,\sor\sis\sit\snot\srolled\sback\sonly\sby\saccident?\swill\sit\sbe\sacceptable\sif\sthe\schange\sdescribed\sabove\sis\smade?).\n
J login a_kovalenko
J mimetype text/plain
J username a_kovalenko
K 1256872fffffffffffffffffffffffffffffffff
U a_kovalenko
Z 276419ff1e7a91c2cc2f839759ec326d