Skip to content
Tcl Source Code Artifact [b3d088ecab]
Login

Artifact [b3d088ecab]

Artifact b3d088ecab858738ad9226b3aef77d657d097dee6a80bbcfd67a720089ac95bb:

Ticket change [b3d088ecab] - Ticket [81242a48c80efaec|81242a48c8] <i>Documentation for Tcl_UtfAtIndex() is incorrect</i> status still Open with 4 other changes by jan.nijtmans on 2020-05-12 13:20:04.
D 2020-05-12T13:20:04.967
J assignee jan.nijtmans
J icomment OK,\sbuild\sfailures\scan\sbe\sseen\shere:\s[https://travis-ci.org/github/tcltk/tcl/jobs/685533037https://travis-ci.org/github/tcltk/tcl/jobs/685533037].\r\n\r\nThe\sreason\sfor\sthe\stest\sfailures\sare\sthat\ssequences\sof\s3\scontinuation\sbytes\s(e.g.\s\\xA0\\xA0\\xA0)\sdon't\swork\swell.\sIf\sthey\sare\spreceded\sby\se.g.\s\\xF2,\sit's\sa\svalid\s4-byte\ssequence\saccording\sto\sTIP\s#389.\sBut\sTcl_UtfNext()\sdoesn't\shave\saccess\sto\ssrc[-1].\sTcl_UtfToUniChar()\shas\saccess\sto\sits\sprevious\sbytes,\sbecause\sit\suses\schPtr\sto\sstore\sthe\sprevious\sresult\sof\sTcl_UtfToUniChar().\sIf\sthe\sprevious\sresult\swas\san\supper\ssurrogate,\sTcl_UtfToUniChar()\scan\sconclude\s-\sin\sthis\scase\s-\sthat\sit's\shandling\sa\svalid\s4-byte\sUTF-8\ssequence.\sTcl_UtfNext()\scannot\sdo\sthat.\r\n\r\nSo,\show\sshould\swe\sfix\sthis\sdocumentation?\sThe\seasiest\sfix\sis\ssaying\s"is\s\sequivalent\sto\scalling\r\n-\\fBTcl_UtfToUniChar\\fR\s\\fIindex\\fR\stimes".\sStill\sthat's\snot\s100%\scorrect:\sIn\sthe\sTIP\s#389\simplementation,\sTcl_UtfAtIndex()\sexecutes\sTcl_UtfToUniChar()\sone\sadditional\stime\swhen\sit\sdetects\sthat\sindex\spoints\sin\sthe\smiddle\sof\sa\scharacter\s>U+FFFF.\r\n\r\nSo,\snext\sexperiment:\sWhat\shappens\sif\swe\sdon't\sdo\sthe\sextra\scall\sto\sTcl_UtfToUniChar()\sany\smore?\s\sIf\sthat\sworks,\sthe\sdocumentation\schange\sis\seasy.\sIf\sit\scannot\sbe\sdone,\sthe\sdescription\sbecomes\sa\slittle\sbit\smore\scomplicated.\r\n\r\nWhen\sthis\sdocumentation\swas\swritten,\ssurrogates\sdidn't\sexist\syet\sin\sthe\sUnicode\sstandard.\sCode\spoints\s>\sU+FFFF\sdidn't\sexist\syet\seither.\sSo,\sit's\svery\sunderstandable\sno-one\snoticed\sthis\sup\sto\snow:\sTcl\snever\ssupported\scode\spoints\s>\sU+FFFF\seither.
J login jan.nijtmans
J mimetype text/x-fossil-wiki
K 81242a48c80efaecf2c70271cafa2c2a0a3bf126
U jan.nijtmans
Z 134140722c06b4b9e81d403d214b71a3