Posted to tcl by gwlester at Wed Jun 21 17:37:45 GMT 2017view raw

  1. if {!$state(binary)} {
  2. # If we are getting text, set the incoming channel's encoding
  3. # correctly. iso8859-1 is the RFC default, but this could be any IANA
  4. # charset. However, we only know how to convert what we have
  5. # encodings for.
  6.  
  7. set enc [CharsetToEncoding $state(charset)]
  8. if {$enc ne "binary"} {
  9. set state(body) [encoding convertfrom $enc $state(body)]
  10. }
  11.  
  12. # Translate text line endings.
  13. set state(body) [string map {\r\n \n \r \n} $state(body)]
  14. }