Tcl 文档解释错误吗\xhh
这是来自TCL主文档:Tcl 文档解释错误吗\xhh,tcl,language-lawyer,Tcl,Language Lawyer,这是来自TCL主文档: \xhh The hexadecimal digits hh give an eight-bit hexadecimal value for the Unicode character that will be inserted. Any number of hexadecimal digits may be present; however, **all but the last two are ignored** (the result is always a
\xhh The hexadecimal digits hh give an eight-bit hexadecimal value for the
Unicode character that will be inserted. Any number of hexadecimal digits may be
present; however, **all but the last two are ignored** (the result is always a
one-byte quantity).
我怀疑的是这一部分,除了最后两个,其余都被忽略了
。这是我的实验:
>set a "\x22"
"
>set a "\x2230"
"30
所以你可以看到,它是前两个十六进制数字,其余的被当作普通字符处理
我错过什么了吗
[EDIT]看起来我是对的,这是来自tcl8.6的parser.c:
860 case 'x':
861 count += TclParseHex(p+1, (numBytes > 3) ? 2 : numBytes-2, &result);
因此,只取前两个立即数。奇怪的是,为什么没有人发现这个文档错误。这是一个行为从Tcl 8.5(及之前)变为8.6的地方。这是一个错误修复,因为旧的行为是如此奇怪,没有人会想到它。(或西班牙宗教法庭,但我离题了…) 在第8.6节中: \xhh
十六进制数字hh(其中一个或两个)为将插入的Unicode字符提供八位十六进制值。Unicode字符的高位为0 在8.5中: \xhh
十六进制数字hh给出将插入的Unicode字符的八位十六进制值。可能存在任意数量的十六进制数字;但是,除最后两个外,其余都将被忽略(结果始终为一个字节的数量)。Unicode字符的高位为0 区别是显而易见的,8.5和8.6在这里表现不同。这一变化是由于2011年9月投票通过了“将Unicode文本扩展到BMP之后”(作为通用修复程序的一部分,其中一些修复程序由于对ABI的影响不得不推迟到8.6之后);项目负责人是Jan Nijtmans。 我记得我投了那个建议的票,而那个修正案是我非常高兴的 很抱歉,它没有被标记为潜在的不兼容。错过了那一次(可能是因为旧的行为被严重破坏,以至于没有人真的相信我们很久以前就没有解决它了……)