Posted to tcl by Colin at Tue Sep 18 23:53:55 GMT 2007view raw

  1. # handle charset for text/* types
  2. lassign [split [Dict get? $reply content-type] {;}] ct
  3. if {[string match text/* $ct]} {
  4. if {[dict exists $reply -charset]} {
  5. set charset [dict get $reply -charset]
  6. } else {
  7. set charset utf-8 ;# default charset
  8. }
  9. dict set reply -charset $charset
  10. dict set reply -chconverted $charset
  11. dict set reply content-type "$ct; charset=$charset"
  12. dict set reply -content [encoding convertto $charset [dict get $reply -content]]
  13. }
  14.