Re: Decoding CJK characters to unicode in Tcl



Tcl natively uses Unicode for (almost) all strings.
Does this example from an interactive wish help?

proc u2x str {
set res {}
foreach c [split $str ""] {
scan $c %c i
append res [expr {$i>127? "\\u[format %04.4x $i]" : $c}]
}
set res
}
166 % u2x "太 酷 - very cool"
\u592a \u9177 - very cool

.



Relevant Pages