其他分享
首页 > 其他分享> > tcl/string/20200225 fromCharCode, toCharCode

tcl/string/20200225 fromCharCode, toCharCode

作者:互联网

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.

标签:set,string,108,toCharCode,20200225,tcl,String,111,fromCharCode
来源: https://www.cnblogs.com/GCxokoA/p/12361420.html