acs_mail_lite::utils::build_subject (private)
acs_mail_lite::utils::build_subject [ -charset charset ] subject
Defined in packages/acs-mail-lite/tcl/utils-procs.tcl
Encode the subject, using quoted-printable, of an email message and trim long lines. Depending on the available mime package version, it uses either the mime::word_encode proc to do it or local code (word_encode is buggy in mime < 1.5.2 ) A purely tcllib based version would be [mime::word_encode utf-8 quoted-printable $subject] but that would miss the safety-belt for newline handling
- Switches:
- -charset (optional, defaults to
"UTF-8"
)- Parameters:
- subject (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: set charset [string toupper $charset] set charset_code [ns_encodingforcharset $charset] # maxlen for each line # 69 = 76 - 7 where 7 is for "=?"+"?Q?+"?=" set maxlen [expr {69 - [string length $charset]}] # # Make sure, the subject line does not have surrounding white # space/new lines # set subject [string trim $subject] if {[regsub -all -- {[\r\n]} $subject " " s]} { ad_log warning "subject line contains line breaks (replaced by space): '$subject' -> '$s'" set subject $s } # # set up variables for loop # set result "" set line "" set i 0 set subject_length [string length $subject] while { $i < $subject_length } { set chunk [string index $subject $i] # encode that chunk set chunk [encoding convertto $charset_code "$chunk"] if { $chunk eq "\x3F" } { # ER: workaround (kludge!) for tcllib error set chunk "=3F" } else { set chunk [mime::qp_encode "$chunk" 1 0] } set newline $line append newline $chunk if { [string length $newline] <= $maxlen } { append line $chunk } else { append result "=?$charset?Q?$line?=\n " set line $chunk } incr i } if { $line ne "" } { append result "=?$charset?Q?$line?=" } return $resultXQL Not present: Generic, PostgreSQL, Oracle