spam_encode_quoted_printable

one of the documented procedures in this installation of the ACS
Usage:
spam_encode_quoted_printable   msg
What it does:
Returns a MIME quoted-printable RFC1521 encoded string
Defined in: /web/philip/tcl/spam-defs.tcl

Source code:


    ns_share spam_quoted_printable_en

    set result {}
    regsub -all "\r" $msg "" msg_stripped
    set length 0
    set strlen [string length $msg_stripped]
    for {set i 0} {$i < $strlen} {incr i} {
	set c [string range $msg_stripped $i $i]
	set c2 [string range $msg_stripped [expr $i + 1] [expr $i + 1]]
	scan $c "%c" x
	scan $c2 "%c" x2
	# if c is a SPACE or TAB, and next char is LF, encode C as QP
	if {(($x == 32) || ($x == 9)) && ($x2 == 10)} {
	    set qp [format "=%X%X" [expr (($x >> 4) & 0xF)] [expr ($x & 0xF)]]
	    incr length [string length $qp]
	    append result $qp
	} elseif {$x == 10} {
	    # hard line break (ASCII 10) requires conversion to MIME CRLF
	    append result "\r\n"
	    set length 0
	} else {
	    set qp $spam_quoted_printable_en($x)
	    incr length [string length $qp]
	    append result $qp
	}

	# Make soft line break at 75 characters.
	if {$length > 72} {
	    append result "=\n"
	    set length 0
	}
    }
    return $result


philg@mit.edu