Defined in
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
-
No testcase defined.
Source code:
variable encodings
if {![info exists encodings($charset)]} {
error "unknown charset '$charset'"
}
if {$encodings($charset) eq {}} {
error "invalid charset '$charset'"
}
if {$method ne "base64" && $method ne "quoted-printable"} {
error "unknown method '$method', must be base64 or quoted-printable"
}
array set options [list -charset_encoded 1 -maxlength 66]
array set options $args
if {$options(-charset_encoded)} {
set unencoded_string [::encoding convertfrom $charset $string]
} else {
set unencoded_string $string
}
set string_length [string length $unencoded_string]
if {!$string_length} {
return {}
}
set string_bytelength [string bytelength $unencoded_string]
set maxlength [expr {$options(-maxlength) - [string length $encodings($charset)] - 7}]
switch -exact -- $method {
base64 {
if {$maxlength < 4} {
error "maxlength $options(-maxlength) too short for chosen charset and encoding"
}
set count 0
set maxlength [expr {($maxlength / 4) * 3}]
while {$count < $string_length} {
set length 0
set enc_string {}
while {($length < $maxlength) && ($count < $string_length)} {
set char [string range $unencoded_string $count $count]
set enc_char [::encoding convertto $charset $char]
if {($length + [string length $enc_char]) > $maxlength} {
set length $maxlength
} else {
append enc_string $enc_char
incr count
incr length [string length $enc_char]
}
}
set encoded_word [string map [
list \n {}] [base64 -mode encode -- $enc_string]]
append result "=?$encodings($charset)?B?$encoded_word?=\n "
}
set result [string range $result 0 end-2]
}
quoted-printable {
if {$maxlength < 1} {
error "maxlength $options(-maxlength) too short for chosen charset and encoding"
}
set count 0
while {$count < $string_length} {
set length 0
set encoded_word {}
while {($length < $maxlength) && ($count < $string_length)} {
set char [string range $unencoded_string $count $count]
set enc_char [::encoding convertto $charset $char]
set qp_enc_char [qp_encode $enc_char 1]
set qp_enc_char_length [string length $qp_enc_char]
if {$qp_enc_char_length > $maxlength} {
error "maxlength $options(-maxlength) too short for chosen charset and encoding"
}
if {($length + [
string length $qp_enc_char]) > $maxlength} {
set length $maxlength
} else {
append encoded_word $qp_enc_char
incr count
incr length [string length $qp_enc_char]
}
}
append result "=?$encodings($charset)?Q?$encoded_word?=\n "
}
set result [string range $result 0 end-2]
}
{} {
}
default {
error "Can't handle content encoding \"$method\""
}
}
return $result
XQL Not present:Generic, PostgreSQL, Oracle