mime::qp_encode (private)
mime::qp_encode string [ encoded_word ] [ no_softbreak ]
Defined in packages/acs-tcl/tcl/tcllib-doc-procs.tcl
Encode quoted-printable content using a Tcllib MIME implementation helper. This non-exported helper is version-dependent.
- Parameters:
- string (required)
- Data to encode.
- encoded_word (optional, defaults to
"0")- Use encoded-word processing when true.
- no_softbreak (optional, defaults to
"0")- Suppress insertion of soft line breaks when true.
- Returns:
- Quoted-printable text.
- See Also:
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: # 8.1+ improved string manipulation routines used. # Replace outlying characters, characters that would normally # be munged by EBCDIC gateways, and special Tcl characters "[\]{} # with =xx sequence regsub -all -- {[\x00-\x08\x0B-\x1E\x21-\x24\x3D\x40\x5B-\x5E\x60\x7B-\xFF]} $string {[format =%02X [scan "\\&" %c]]} string # Replace the format commands with their result set string [subst -novariables $string] # soft/hard newlines and other # Funky cases for SMTP compatibility set mapChars [ list " \n" =20\n \t\n =09\n \n\.\n \=2E\n "\nFrom " "\n=46rom "] if {$encoded_word} { # Special processing for encoded words (RFC 2047) lappend mapChars { } _ } set string [string map $mapChars $string] # Break long lines - ugh # Implementation of FR #503336 if {$no_softbreak} { set result $string } else { set result {} foreach line [split $string \n] { while {[string length $line] > 72} { set chunk [string range $line 0 72] if {[regexp -- (=|=.)$ $chunk dummy end]} { # Don't break in the middle of a code set len [expr {72 - [string length $end]}] set chunk [string range $line 0 $len] incr len set line [string range $line $len end] } else { set line [string range $line 73 end] } append result $chunk=\n } append result $line\n } # Trim off last \n, since the above code has the side-effect # of adding an extra \n to the encoded string and return the # result. set result [string range $result 0 end-1] } # If the string ends in space or tab, replace with =xx set lastChar [string index $result end] if {$lastChar eq { }} { set result [string replace $result end end =20] } elseif {$lastChar eq "\t"} { set result [string replace $result end end =09] } return $resultXQL Not present: Generic, PostgreSQL, Oracle