Posted to tcl by stevel at Thu Jun 12 07:30:19 GMT 2008view raw

  1. proc u2a {s} {
  2. set res ""
  3. foreach i [split $s ""] {
  4. scan $i %c c
  5. if {$c<128} {append res $i} else {append res \\u[format %04.4X $c]}
  6. }
  7. return $res
  8. }
  9.  
  10. puts -nonewline "input: " ; flush stdout
  11. while {[gets stdin line] >= 0} {
  12. puts [u2a $line]
  13. puts -nonewline "input: " ; flush stdout
  14. }