proc String.fromCharCode {args} { set s [binary format s* $args] encoding convertfrom unicode $s } proc String.toCharCode {s} { set s [encoding convertto unicode $s] binary scan $s s* x;set x }
示例:
$ String.toCharCode hello > 104 101 108 108 111 $ String.toCharCode 你好 > 20320 22909 $ String.fromCharCode 104 101 108 108 111 > hello $ String.fromCharCode 20320 22909 > 你好
done.