這是從主TCL DOC:是該文檔錯誤有關解釋 XHH
\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).
我的疑問是這一部分,all but the last two are ignored
。這裏是我的實驗:
>set a "\x22"
"
>set a "\x2230"
"30
所以你可以看到,這是採取第2個十六進制數字,其餘都只是當作普通的字符。
我想念什麼?
[編輯]好像我是對的,這裏是從tcl8.6的parser.c:
860 case 'x':
861 count += TclParseHex(p+1, (numBytes > 3) ? 2 : numBytes-2, &result);
所以只能採取第一個直接2個位數。奇怪,爲什麼沒有人發現這個文檔錯誤。