.
D 2000-10-26T00:57:33
J assignee nobody
J cmimetype text/plain
J comment OriginalBugID:\s6096\sBug\nVersion:\s8.2.1\nSubmitDate:\s'2000-08-09'\nLastModified:\s'2000-08-10'\nSeverity:\sSER\nStatus:\sClosed\nSubmitter:\stechsupp\nChangedBy:\sericm\nRelatedBugIDs:\s3345\nOS:\sDigital\sUnix\nOSVersion:\sTru64\sUNIX\sVersion\s5.1\nMachine:\sDigital\sPersonal\sWorkStation\s500au\s(Alpha)\nFixedDate:\s'2000-10-25'\nClosedDate:\s'2000-08-10'\n\n\nName:\n\nRigoberto\sCorujo\n\n\nExtensions:\n\nTclX\s8.1\n\n\nReproducibleScript:\n\nWhen\srunning\sExtended\sTcl\son\sTru64\sUNIX\swith\sa\sdechanzi\sChinese\slocale,\sthe\soutput\sof\sthe\sfollowing\scommand\sis\snot\sproperly\sdisplayed.\s\sThat\sis,\ssome\sof\sthe\sdate\soutput\scontains\s"?"\scharacters.\n\n\n$\stcl\n\ntcl>puts\s"[fmtclock\s[getclock]]"\n\n\nThis\sis\sbecause\sthe\soutput\sof\s"fmtclock"\sis\snot\sUTF-8\sencoded,\sbut\s"puts",\sor\srather\sthe\s"WriteChars()"\sroutine\sthat\simplements\sthe\s"puts"\scommand,\sexpects\sthe\sstring\sit\sis\sprocessing\sto\sbe\sUTF-8\sencoded.\s\sRunning\sthe\sfollowing\scommand\sproduces\sthe\scorrect\soutput,\showever,\swhich\smeans\sthat\s"puts"\sneeds\sto\sbe\sfixed.\n\n\n$\stcl\n\ntcl>fmtclock\s[getclock]\n\n\nThe\s"WriteChars()"\sroutine\s("./tcl8.2/generic/tclIO.c")\sshould\saccept\sstrings\sthat\sare\sUTF-8\sencoded\sand\sstrings\sthat\sare\slocally\sencoded.\s\sIf\sthe\sstring\sis\salready\slocally\sencoded,\sthen\sit\sshould\snot\stry\sto\sdo\sthe\sUTF-8\sto\slocal\sencoding.\n\n\nObservedBehavior:\n\nSome\squestion\smarks\s("?")\sare\sdisplayed\sin\sthe\sdate\sstring\sthat\sis\soutput.\n\n\nDesiredBehavior:\n\nThe\soutput\sof\n\n\ntcl>puts\s"[fmtclock\s[getclock]]"\n\n\nshould\sbe\sthe\ssame\sas\n\n\ntcl>fmtclock\s[getclock]\n\n\nSince\sthe\soutput\sis\sin\sChinese\sI\swill\snot\sshow\sit\shere\sas\sit\swill\slikely\snot\sdisplay\sproperly\son\sa\sbrowser.\n\n\nPatch:\n\nOne\sof\sour\sI18N\sengineers\sprovided\sthe\sfollowing\spatch\sas\sa\sworkaround,\sbut\scautioned\sthat\sa\smore\scomprehensive\ssolution\sis\sneeded\swhich\srequires\sknoUTF-8\sand\snon-UTF-8\sstrings\sget\spassed\samong\sthe\sdifferent\smodules.\n\n\n$\sdiff\s-c\stclIO.c.old\stclIO.c.new\s>\stclIO.c.patch\s\n\n$\scat\stclIO.c.patch\n\n***\stclIO.c.old\sWed\sAug\s\s2\s08:43:52\s2000\n\n---\stclIO.c.new\sWed\sAug\s\s2\s08:43:57\s2000\n\n***************\n\n***\s2984,2990\s****\n\n---\s2984,3001\s----\n\n\s\s\s\s\s\sint\sdstWrote,\sdstLen,\sstageLen,\sstageMax,\sstageRead;\n\n\s\s\s\s\s\sTcl_Encoding\sencoding;\n\n\s\s\s\s\s\schar\ssafe[BUFFER_PADDING];\n\n+\s#ifndef\s\s\s\s\s\s\sNO_DEC_I18N\n\n+\s\s\s\s\sextern\sint\sTcl_IsWellFormUtf8(uchar_t\s*,\sint)\s;\n\n\n+\s\s\s\s\s/*\n\n+\s\s\s\s\s\s*\sQAR\s81435\n\n+\s\s\s\s\s\s*\sAssume\sstring\sis\sin\snative\sencoding\sif\sit\sis\snot\sa\swell-form\n\n+\s\s\s\s\s\s*\sUTF-8\ssequence.\n\n+\s\s\s\s\s\s*/\n\n+\s\s\s\s\sif\s(!Tcl_IsWellFormUtf8((uchar_t\s*)src,\ssrcLen))\n\n+\s\s\s\s\s\s\sreturn(WriteBytes(chanPtr,\ssrc,\ssrcLen))\s;\n\n+\s#endif\n\n+\s\n\n\s\s\s\s\s\stotal\s=\s0;\n\n\s\s\s\s\s\ssawLF\s=\s0;\n\n\s\s\s\s\s\ssavedLF\s=\s0;\n\n\n$\sdiff\s-c\stclUtf.c.old\stclUtf.c.new\s>\stclIO.c.patch\n\n$\scat\stclIO.c.patch\n\n***\stclUtf.c.old\s\s\s\s\s\s\s\sWed\sAug\s\s2\s08:45:31\s2000\n\n---\stclUtf.c.new\s\s\s\s\s\s\s\sWed\sAug\s\s2\s08:45:38\s2000\n\n***************\n\n***\s1581,1583\s****\n\n---\s1581,1621\s----\n\n\n\s\s\s\s\s\sreturn\s(((ALPHA_BITS\s|\sDIGIT_BITS\s|\sCONNECTOR_BITS)\s>>\scategory)\s&\s1);\n\n\s\s}\n\n+\s\n\n+\s\n\n\n+\s#ifndef\s\s\s\s\s\s\sNO_DEC_I18N\n\n+\s/*\n\n+\s\s*----------------------------------------------------------------------\n\n+\s\s*\n\n+\s\s*\sTcl_IsWellFormUtf8\n\n+\s\s*\n\n+\s\s*\s\s\s\sTest\sif\sa\sstring\sis\sa\swell-form\sUTF-8\ssequence.\n\n+\s\s*\n\n+\s\s*\sResults:\n\n+\s\s*\s\s\s\sReturns\s1\sif\sstring\sis\sa\swell-form\sUTF-8\ssequence.\n\n+\s\s*\n\n+\s\s*\sSide\seffects:\n\n+\s\s*\s\s\s\sNone.\n\n+\s\s*\n\n+\s\s*----------------------------------------------------------------------\n\n+\s\s*/\n\n+\s#define\s\s\s\s\s\s\sTCL_VALID_UTF8_NONFIRSTBYTE(b)\s\s(((b)\s&\s0xc0)\s==\s0x80)\n\n+\sint\n\n+\sTcl_IsWellFormUtf8(uchar_t\s*str,\sint\slength)\n\n+\s{\n\n+\s\s\s\s\sint\sch,\slen\s;\n\n+\s\n\n+\s\s\s\s\swhile\s(length--\s>\s0)\n\n+\s\s\s\s\s{\n\n+\s\s\s\s\s\s\sch\s=\s*str++\s;\n\n+\s\s\s\s\s\s\sif\s(isascii(ch))\n\n+\s\s\s\s\s\s\s\s\s\s\scontinue\s;\n\n+\s\s\s\s\s\s\sif\s((len\s=\stotalBytes[ch]\s-\s1)\s<=\s0)\n\n+\s\s\s\s\s\s\s\s\s\s\sreturn(0)\s;\s/*\sInvalid\sUTF-8\ssequence\s*/\n\n+\s\s\s\s\s\s\swhile\s(len--\s>\s0)\n\n+\s\s\s\s\s\s\s\s\s\s\sif\s(!TCL_VALID_UTF8_NONFIRSTBYTE(*str++))\n\n+\s\s\s\s\s\s\s\s\s\s\s\s\s\s\sreturn(0)\s;\n\n+\s\s\s\s\s}\n\n+\s\s\s\s\sreturn(1)\s;\s\s\s\s\s\s\s/*\sWell-form\sUTF-8\ssequence\s*/\n\n+\s}\n\n+\s#endif\n\n\nPatchFiles:\n\n./tcl8.2/generic/tclIO.c\n\n\s\s\s\s./tcl8.2/generic/tclUtf.c\n\n\n\n\nAs\swas\sdiscussed\sin\sthe\snewsgroup,\s[puts]\sshould\snot\shave\sto\shandle\snon-UTF-8\sstrings,\sas\sit\sis\spart\sof\sthe\s"API\scontract"\sthat\sWriteChars\sis\sgiven\sUTF-8\sstrings.\n\nSo\sit\sis\sfair\sto\ssay\sthat\sthe\sproblem\sshould\sbe\ssolved\sin\s[fmtclock];\showever,\sthat\sdoesn't\sreally\sgive\sthe\swhole\sstory.\s\sSince\sTclX\s7.5,\s[fmtclock]\shas\ssimply\sbeen\san\salias\sto\s[clock\sformat].\s\sThere\swas\sa\sbug\sin\s[clock\sformat]\sthat\scaused\sit\sto\sreturn\snon-UTF-8\sstrings,\swhich\sonly\sshowed\sup\swhen\sused\sin\slocales\slike\sthe\sone\syou\sused.\s\sThis\sbug\swas\scorrected\sfor\s8.4a1,\sand\sthe\sfix\swas\sbackported\sfor\s8.3.2.\s\sI\ssuggest\sthat\syou\supgrade\syour\sTcl\sinstallation\sto\sthat\sversion.\n\n\s\s\sEric\sMelski\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\sThe\sOther\sTcl\sGuy\n\s\s\sericm\sat\sajubasolutions.com\s\s\s\s\s\s\s\s\s\s\s\sAjuba\sSolutions\n\n--\s08/10/2000\sericm\n\n
J foundin obsolete:\s8.2.1
J priority 5\sMedium
J resolution None
J status Open
J submitter nobody
J subsystem 69.\sOther
J title "puts"\sdoes\snot\swork\swith\snon\sUTF-8\sstrings
J type Bug
K 218434ffffffffffffffffffffffffffffffffff
U nobody
Z 2054955d72e1e6bdd81ab81790b4d524